/// <summary> /// Decodes the specified sender. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="GameObjectTeleportEventArgs" /> instance containing the event data.</param> /// <returns>Struct.</returns> public static Struct Decoded(GameObject sender, GameObjectTeleportEventArgs args) // { var result = new Struct { Status = Status.Unknown, Type = Type.Unknown }; if (sender == null || !sender.IsValid || !(sender is Obj_AI_Hero)) { return(result); } result.UnitNetworkId = sender.NetworkId; var hero = sender as Obj_AI_Hero; if (!RecallDataByNetworkId.ContainsKey(result.UnitNetworkId)) { RecallDataByNetworkId[result.UnitNetworkId] = new TeleportData { Type = Type.Unknown }; } if (!string.IsNullOrEmpty(args.RecallType)) { if (TypeByString.ContainsKey(args.RecallType)) { ITeleport teleportMethod = TypeByString[args.RecallType]; var duration = teleportMethod.GetDuration(args); var type = teleportMethod.Type; var time = Utils.TickCount; RecallDataByNetworkId[result.UnitNetworkId] = new TeleportData { Duration = duration, Type = type, Start = time }; result.Status = Status.Start; result.Duration = duration; result.Type = type; result.Start = time; } } else { var shorter = Utils.TickCount - RecallDataByNetworkId[result.UnitNetworkId].Start < RecallDataByNetworkId[result.UnitNetworkId].Duration - ErrorGap; result.Status = shorter ? Status.Abort : Status.Finish; result.Type = RecallDataByNetworkId[result.UnitNetworkId].Type; result.Duration = 0; result.Start = 0; } return(result); }
//Excute a command by using command build in execute function //and set current index to right number public static void ExcuteCommand(ITeleport tel, Vector3 pos) { var markPositionCommand = new MarkPositionCommand(tel, pos); if (_currentCommandIndex != _commands.Count - 1) { int count = _commands.Count - 1; for (int i = count; i > _currentCommandIndex; i--) { _commands.RemoveAt(i); } } _commands.Add(markPositionCommand); markPositionCommand.Execute(); _currentCommandIndex++; }
public Command(ITeleport teleport) { _teleport = teleport; }
public MarkPositionCommand(ITeleport teleport, Vector3 position) : base(teleport) { _position = position; }
public TeleportingAI(Enemy controllingEnemy, Direction direction) : base(controllingEnemy) { teleportableEnemy = controllingEnemy as ITeleport; teleportTimer = 0f; TeleDirection = direction.ToVector2(); }
public override void Update() { if (!this._initLinks) { this._initLinks = true; Vec2 vec2 = new Vec2(0.0f, -1f); if (this.direction == 1) { vec2 = new Vec2(0.0f, 1f); } else if (this.direction == 2) { vec2 = new Vec2(-1f, 0.0f); } else if (this.direction == 3) { vec2 = new Vec2(1f, 0.0f); } this._link = Level.CheckRay <Teleporter>(this.position + new Vec2(0.0f, -8f) + vec2 * 20f, this.position + new Vec2(0.0f, -8f) + vec2 * 5000f); this._dir = vec2; } if (this._link == null) { return; } IEnumerable <ITeleport> source = Level.CheckRectAll <ITeleport>(this.topLeft, this.bottomRight); for (int index = 0; index < this._teleported.Count; ++index) { ITeleport teleport = this._teleported[index]; if (!source.Contains <ITeleport>(teleport)) { this._teleported.RemoveAt(index); --index; } } foreach (ITeleport teleport1 in source) { if (this.noduck.value) { switch (teleport1) { case Duck _: case Ragdoll _: case RagdollPart _: case TrappedDuck _: continue; } } ITeleport teleport2 = teleport1; if ((teleport2 as Thing).owner == null && (teleport2 as Thing).isServerForObject && (!this._teleported.Contains(teleport2) && !this._teleporting.Contains(teleport2))) { this._teleporting.Add(teleport2); } } int num1; for (int index1 = 0; index1 < this._teleporting.Count; index1 = num1 + 1) { Thing thing = this._teleporting[index1] as Thing; this._teleporting.RemoveAt(index1); for (int index2 = 0; index2 < 2; ++index2) { Level.Add((Thing)SmallSmoke.New(thing.position.x + Rando.Float(-8f, 8f), thing.position.y + Rando.Float(-8f, 8f))); } Vec2 position1 = thing.position; thing.position = this._link.position - (this.position - thing.position); if (thing is RagdollPart) { thing.position.y = this._link.position.y; } this._link._teleported.Add(thing as ITeleport); if (thing is PhysicsObject) { if ((double)thing.hSpeed > 0.0) { thing.position.x = this._link.position.x + 8f; } else { thing.position.x = this._link.position.x - 8f; } } for (int index2 = 0; index2 < 2; ++index2) { Level.Add((Thing)SmallSmoke.New(thing.position.x + Rando.Float(-8f, 8f), thing.position.y + Rando.Float(-8f, 8f))); } num1 = index1 - 1; Vec2 vec2 = position1; Vec2 position2 = thing.position; if (thing is Duck && (thing as Duck).sliding) { vec2.y += 9f; position2.y += 9f; } if ((double)this._dir.y != 0.0) { vec2.x = this.position.x; position2.x = this._link.position.x; } float num2 = Math.Max((double)this._dir.x != 0.0 ? thing.height : thing.width, 8f); this.warpLines.Add(new WarpLine() { start = vec2, end = position2, lerp = 0.6f, wide = num2 }); thing.OnTeleport(); } }