public MsgClientEvent(MsgClientEvent copy) : base(ACSProtocol.MessageType.ACSP_CLIENT_EVENT) { Subtype = copy.Subtype; CarId = copy.CarId; OtherCarId = copy.OtherCarId; RelativeVelocity = copy.RelativeVelocity; WorldPosition = copy.WorldPosition; // wrong, should really copy this RelativePosition = copy.RelativePosition; // wrong, should really copy this }
public MsgClientEvent(MsgClientEvent copy) : base(ACSProtocol.MessageType.ACSP_CLIENT_EVENT) { Subtype = copy.Subtype; CarId = copy.CarId; OtherCarId = copy.OtherCarId; RelativeVelocity = copy.RelativeVelocity; WorldPosition = copy.WorldPosition; // wrong, should really copy this RelativePosition = copy.RelativePosition;// wrong, should really copy this }
protected internal virtual void OnCollision(MsgClientEvent msg) { }
protected override void OnCollision(MsgClientEvent msg) { if (msg.Subtype == (byte)ACSProtocol.MessageType.ACSP_CE_COLLISION_WITH_CAR) { // TODO: Messy code. Needs rewrite as soon as I know where I'm heading. // We'll check if the contact partners are part of an contact tree bool partOfATree = false; int bagId = -1; lock (contactTrees) { foreach (var ct in contactTrees) { // If both can't be put into the contact tree, we'll treat this as new if (ct.TryAdd(msg.CarId, msg.OtherCarId)) { partOfATree = true; bagId = ct.BagId; break; } } PluginManager.Log("" + DateTime.Now.TimeOfDay + " OnCollision (" + msg.CarId + "vs" + msg.OtherCarId + "), contantTrees.Count=" + contactTrees.Count + ", partOfATree=" + partOfATree); if (!partOfATree) { // Then we'll start a new one var newBag = CollisionBag.StartNew(msg.CarId, msg.OtherCarId, EvaluateContactTree, PluginManager); contactTrees.Add(newBag); bagId = newBag.BagId; } } TrySendCollision(CurrentSessionGuid, msg.CreationDate, msg.CarId, msg.OtherCarId, msg.RelativeVelocity, msg.RelativePosition.X, msg.RelativePosition.Z, msg.WorldPosition.X, msg.WorldPosition.Z, bagId); } else { PluginManager.Log("Collision occured!!! " + msg.CarId + " vs. wall"); TrySendCollision(CurrentSessionGuid, msg.CreationDate, msg.CarId, -1, msg.RelativeVelocity, msg.RelativePosition.X, msg.RelativePosition.Z, msg.WorldPosition.X, msg.WorldPosition.Z, -1); } }