本文整理汇总了C#中OpenSim.Framework.ColliderArgs类的典型用法代码示例。如果您正苦于以下问题:C# ColliderArgs类的具体用法?C# ColliderArgs怎么用?C# ColliderArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColliderArgs类属于OpenSim.Framework命名空间,在下文中一共展示了ColliderArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TriggerScriptColliding
public void TriggerScriptColliding(SceneObjectPart part, ColliderArgs colliders)
{
ScriptColliding handlerColliding = OnScriptColliding;
if (handlerColliding != null)
{
foreach (ScriptColliding d in handlerColliding.GetInvocationList())
{
try
{
d(part, colliders);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerScriptColliding failed - continuing. {0} {1}",
e.ToString(), e.StackTrace);
}
}
}
}
示例2: HandleGenericCollisionEvent
private void HandleGenericCollisionEvent(CollisionEventUpdate update, Scenes.ScriptEvents eventType, EventManager.ScriptColliding callback,
bool playSound)
{
// play the sound.
if (playSound && CollisionSound != UUID.Zero && eventType == ScriptEvents.collision_start && CollisionSoundVolume > 0.0f)
{
SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0);
}
SceneObjectPart handlingPart = FindCollisionHandlingPart(eventType);
if (handlingPart == null) return; //no one to handle the event
ColliderArgs colliderArgs = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
bool otherIsPrim;
if (update.Type == CollisionEventUpdateType.CollisionBegan ||
update.Type == CollisionEventUpdateType.CollisionContinues ||
update.Type == CollisionEventUpdateType.BulkCollisionsContinue ||
update.Type == CollisionEventUpdateType.CollisionEnded)
{
otherIsPrim = true;
}
else
{
otherIsPrim = false;
}
if (update.BulkCollisionData == null)
{
TryExtractCollider(update.OtherColliderLocalId, colliding, otherIsPrim, update.OtherColliderUUID);
}
else
{
foreach (uint localId in update.BulkCollisionData)
{
TryExtractCollider(localId, colliding, otherIsPrim, update.OtherColliderUUID);
}
}
if (colliding.Count > 0)
{
colliderArgs.Colliders = colliding;
// always running this check because if the user deletes the object it would return a null reference.
if (m_parentGroup == null)
return;
if (m_parentGroup.Scene == null)
return;
callback(handlingPart.LocalId, colliderArgs);
}
}
示例3: DoNotify
private void DoNotify(ScriptCollidingNotification notify, uint id, ColliderArgs collargs)
{
if (m_parentGroup != null && ParentGroup.Scene != null && ParentGroup.Scene.ShouldUseFireAndForgetForCollisions)
{
// For those learning C#, FireAndForget takes a function, an object to pass
// to that function and an ID string. The "oo => {}" construct is a lambda expression
// for a function with one arguement ('oo'). The 'new Object[] {}" construct creates an Object
// that is an object array and initializes it with three items (the parameters
// being passed). The parameters passed are the function to call ('notify') and
// its two arguements. Finally, once in the function (called later by the FireAndForget
// thread scheduler), the passed object is cast to an object array and then each
// of its items (aoo[0] to aoo[2]) are individually cast to what they are and
// then used in a call of the passed ScriptCollidingNotification function.
Util.FireAndForget(oo =>
{
Object[] aoo = (Object[])oo;
((ScriptCollidingNotification)aoo[0])((uint)aoo[1], (ColliderArgs)aoo[2]);
}, new Object[] { notify, id, collargs }, "SOP.Collision");
}
else
{
notify(id, collargs);
}
}
示例4: TriggerScriptCollidingEnd
public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders)
{
handlerCollidingEnd = OnScriptCollidingEnd;
if (handlerCollidingEnd != null)
handlerCollidingEnd(localId, colliders);
}
示例5: SendLandCollisionEvent
private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify)
{
if ((dest.RootPart.ScriptEvents & ev) != 0)
{
ColliderArgs LandCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
colliding.Add(CreateDetObjectForGround());
LandCollidingMessage.Colliders = colliding;
notify(dest.RootPart.LocalId, LandCollidingMessage);
}
}
示例6: collision_start
public void collision_start (ISceneChildEntity part, ColliderArgs col)
{
// Add to queue for all scripts in ObjectID object
List<DetectParams> det = new List<DetectParams>();
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Key = detobj.keyUUID;
d.Populate(part.ParentEntity.Scene);
d.LinkNum = part.LinkNum;
det.Add(d);
}
if (det.Count > 0)
{
ScriptData[] datas = ScriptEngine.ScriptProtection.GetScripts(part.UUID);
if (datas == null || datas.Length == 0)
{
//datas = ScriptEngine.ScriptProtection.GetScripts(part.ParentGroup.RootPart.UUID);
//if (datas == null || datas.Length == 0)
return;
}
string functionName = "collision_start";
object[] param = new Object[] { new LSL_Types.LSLInteger(det.Count) };
foreach (ScriptData ID in datas)
{
if (CheckIfEventShouldFire(ID, functionName, param))
m_scriptEngine.AddToScriptQueue(ID, functionName, det.ToArray(), EventPriority.FirstStart, param);
}
}
}
示例7: collision_end
public void collision_end(uint localID, ColliderArgs col)
{
// Add to queue for all scripts in ObjectID object
List<DetectParams> det = new List<DetectParams>();
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Key =detobj.keyUUID;
d.Populate(myScriptEngine.World);
det.Add(d);
}
if (det.Count > 0)
myScriptEngine.PostObjectEvent(localID, new EventParams(
"collision_end",
new Object[] { new LSL_Types.LSLInteger(det.Count) },
det.ToArray()));
}
示例8: TriggerScriptLandCollidingEnd
public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders)
{
ScriptColliding handlerLandCollidingEnd = OnScriptLandColliderEnd;
if (handlerLandCollidingEnd != null)
{
foreach (ScriptColliding d in handlerLandCollidingEnd.GetInvocationList())
{
try
{
d(localId, colliders);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerScriptLandCollidingEnd failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
示例9: HandleScriptColliding
private void HandleScriptColliding(uint localID, ColliderArgs colliders)
{
SceneObjectPart part = m_scriptEngine.World.GetSceneObjectPart(localID);
if (part != null)
{
//filter out regular collision
//might be fun though later on
if (part.VolumeDetectActive)
{
foreach (DetectedObject obj in colliders.Colliders)
{
EntityBase eb = null;
if (m_scriptEngine.World.Entities.TryGetValue(obj.keyUUID, out eb))
{
OnPrimVolumeCollision(localID, eb.LocalId);
}
else
m_log.Warn("[RexScriptEngine]: Could not find object with id " + obj.keyUUID);
}
}
}
else
m_log.Warn("[RexScriptEngine]: Could not find object with id "+localID);
}
示例10: TriggerScriptLandColliding
public void TriggerScriptLandColliding (ISceneChildEntity part, ColliderArgs colliders)
{
ScriptColliding handlerLandColliding = OnScriptLandColliding;
if (handlerLandColliding != null)
{
foreach (ScriptColliding d in handlerLandColliding.GetInvocationList ())
{
try
{
d (part, colliders);
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat (
"[EVENT MANAGER]: Delegate for TriggerScriptLandColliding failed - continuing. {0} {1}",
e, e.StackTrace);
}
}
}
}
示例11: PhysicsCollision
//.........这里部分代码省略.........
SendSound(SoundPlasticCollision, 1, true, 0, 0, false, false);
else if (m_material == OpenMetaverse.Material.Rubber)
SendSound(SoundRubberCollision, 1, true, 0, 0, false, false);
else if (m_material == OpenMetaverse.Material.Stone)
SendSound(SoundStoneCollision, 1, true, 0, 0, false, false);
else if (m_material == OpenMetaverse.Material.Wood)
SendSound(SoundWoodCollision, 1, true, 0, 0, false, false);
break; //Play based on material type in prim2prim collisions
default:
break; //Unclear of what this object is, no sounds
}
}
if (CollisionSprite != UUID.Zero && CollisionSoundVolume > 0.0f) // The collision volume isn't a mistake, its an SL feature/bug
{
// TODO: make a sprite!
}
if (((AggregateScriptEvents & scriptEvents.collision) != 0) ||
((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
(CollisionSound != UUID.Zero) ||
PassCollisions != 2)
{
if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0)
{
// do event notification
if (startedColliders.Count > 0)
{
ColliderArgs StartCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in startedColliders)
{
if (localId == 0)
continue;
// always running this check because if the user deletes the object it would return a null reference.
if (m_parentGroup == null)
return;
if (m_parentGroup.Scene == null)
return;
SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId);
string data = "";
if (obj != null)
{
if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name))
{
bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
//If it is 1, it is to accept ONLY collisions from this object
if (found)
{
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = obj.UUID;
detobj.nameStr = obj.Name;
detobj.ownerUUID = obj._ownerID;
detobj.posVector = obj.AbsolutePosition;
detobj.rotQuat = obj.GetWorldRotation();
detobj.velVector = obj.Velocity;
detobj.colliderType = 0;
detobj.groupUUID = obj._groupID;
colliding.Add(detobj);
示例12: collision_end
public void collision_end(uint localID, ColliderArgs col)
{
// Add to queue for all scripts in ObjectID object
List<DetectParams> det = new List<DetectParams>();
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = DetectParams.FromDetectedObject(detobj);
det.Add(d);
}
if (det.Count > 0)
myScriptEngine.PostObjectEvent(localID, new EventParams(
"collision_end",
new Object[] { det.Count },
det.ToArray()));
}
示例13: PhysicsCollision
public void PhysicsCollision(EventArgs e)
{
// single threaded here
if (e == null)
{
return;
}
CollisionEventUpdate a = (CollisionEventUpdate)e;
Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList;
List<uint> thisHitColliders = new List<uint>();
List<uint> endedColliders = new List<uint>();
List<uint> startedColliders = new List<uint>();
// calculate things that started colliding this time
// and build up list of colliders this time
foreach (uint localid in collissionswith.Keys)
{
if (localid != 0)
{
thisHitColliders.Add(localid);
if (!m_lastColliders.Contains(localid))
{
startedColliders.Add(localid);
}
//m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
}
}
// calculate things that ended colliding
foreach (uint localID in m_lastColliders)
{
if (!thisHitColliders.Contains(localID))
{
endedColliders.Add(localID);
}
}
//add the items that started colliding this time to the last colliders list.
foreach (uint localID in startedColliders)
{
m_lastColliders.Add(localID);
}
// remove things that ended colliding from the last colliders list
foreach (uint localID in endedColliders)
{
m_lastColliders.Remove(localID);
}
if (m_parentGroup == null)
return;
if (m_parentGroup.IsDeleted)
return;
// play the sound.
if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f)
{
SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0);
}
if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0)
{
// do event notification
if (startedColliders.Count > 0)
{
ColliderArgs StartCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in startedColliders)
{
// always running this check because if the user deletes the object it would return a null reference.
if (m_parentGroup == null)
return;
if (m_parentGroup.Scene == null)
return;
SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId);
if (obj != null)
{
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = obj.UUID;
detobj.nameStr = obj.Name;
detobj.ownerUUID = obj._ownerID;
detobj.posVector = obj.AbsolutePosition;
detobj.rotQuat = obj.GetWorldRotation();
detobj.velVector = obj.Velocity;
detobj.colliderType = 0;
detobj.groupUUID = obj._groupID;
colliding.Add(detobj);
}
else
{
ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
for (int i = 0; i < avlist.Length; i++)
{
ScenePresence av = avlist[i];
if (av.LocalId == localId)
{
//.........这里部分代码省略.........
示例14: land_collision_end
public void land_collision_end(uint localID, ColliderArgs col)
{
List<DetectParams> det = new List<DetectParams>();
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision_end",
new Object[] { new LSL_Types.Vector3(d.Position) },
det.ToArray()));
}
}
示例15: TriggerScriptLandCollidingEnd
public void TriggerScriptLandCollidingEnd (ISceneChildEntity part, ColliderArgs colliders)
{
ScriptColliding handlerLandCollidingEnd = OnScriptLandColliderEnd;
if (handlerLandCollidingEnd != null)
{
foreach (ScriptColliding d in handlerLandCollidingEnd.GetInvocationList ())
{
try
{
d (part, colliders);
}
catch (Exception e)
{
m_log.ErrorFormat (
"[EVENT MANAGER]: Delegate for TriggerScriptLandCollidingEnd failed - continuing. {0} {1}",
e.ToString (), e.StackTrace);
}
}
}
}