public override bool Execute( INamedEntity self, IEntity caller, IInstancedEntity target, MessagePackObject[] arguments) { ICharacter character = (ICharacter)self; int statelId = (int)((uint)0xC0000000 | arguments[1].AsInt32() | (arguments[2].AsInt32() << 16)); character.Stats[StatIds.externaldoorinstance].BaseValue = 0; character.Stats[StatIds.externalplayfieldinstance].BaseValue = 0; if (arguments[1].AsInt32() > 0) { StatelData sd = PlayfieldLoader.PFData[arguments[1].AsInt32()].GetDoor(statelId); if (sd == null) { throw new Exception( "Statel " + arguments[3].AsInt32().ToString("X") + " not found? Check the rdb dammit"); } Vector3 v = new Vector3(sd.X, sd.Y, sd.Z); Quaternion q = new Quaternion(sd.HeadingX, sd.HeadingY, sd.HeadingZ, sd.HeadingW); Quaternion.Normalize(q); Vector3 n = (Vector3)q.RotateVector3(Vector3.AxisZ); v.x += n.x * 2.5; v.z += n.z * 2.5; character.Playfield.Teleport( (Dynel)character, new Coordinate(v), q, new Identity() { Type = (IdentityType)arguments[0].AsInt32(), Instance = arguments[1].AsInt32() }); } return(true); self.Stats[StatIds.externalplayfieldinstance].Value = 0; self.Stats[StatIds.externaldoorinstance].Value = 0; self.Playfield.Teleport( (Dynel)self, new Coordinate(100, 10, 100), ((ICharacter)self).Heading, new Identity() { Type = (IdentityType)arguments[0].AsInt32(), Instance = arguments[1].AsInt32() }); return(true); }
/// <summary> /// Calculate move vector /// </summary> /// <returns>Movevector</returns> private Vector.Vector3 calculateMoveVector() { double forwardSpeed; double strafeSpeed; Vector.Vector3 forwardMove; Vector.Vector3 strafeMove; if (!this.CanMove()) { return(Vector.Vector3.Origin); } forwardSpeed = this.calculateForwardSpeed(); strafeSpeed = this.calculateStrafeSpeed(); if ((forwardSpeed == 0) && (strafeSpeed == 0)) { return(Vector.Vector3.Origin); } if (forwardSpeed != 0) { forwardMove = (Vector.Vector3)Quaternion.RotateVector3(this.RawHeading, Vector.Vector3.AxisZ); forwardMove.Magnitude = Math.Abs(forwardSpeed); if (forwardSpeed < 0) { forwardMove = -forwardMove; } } else { forwardMove = Vector.Vector3.Origin; } if (strafeSpeed != 0) { strafeMove = (Vector.Vector3)Quaternion.RotateVector3(this.RawHeading, Vector.Vector3.AxisX); strafeMove.Magnitude = Math.Abs(strafeSpeed); if (strafeSpeed < 0) { strafeMove = -strafeMove; } } else { strafeMove = Vector.Vector3.Origin; } return(forwardMove + strafeMove); }
public override bool Execute( INamedEntity self, IEntity caller, IInstancedEntity target, MessagePackObject[] arguments) { uint externalDoorInstance = self.Stats[StatIds.externaldoorinstance].BaseValue; int externalPlayfieldId = self.Stats[StatIds.externalplayfieldinstance].Value; StatelData door = PlayfieldLoader.PFData[externalPlayfieldId].Statels.FirstOrDefault( x => (uint)x.Identity.Instance == externalDoorInstance && (x.Identity.Type == IdentityType.Door /*|| x.Identity.Type==IdentityType.MissionEntrance*/)); if (door != null) { Vector3 v = new Vector3(door.X, door.Y, door.Z); Quaternion q = new Quaternion(door.HeadingX, door.HeadingY, door.HeadingZ, door.HeadingW); Quaternion.Normalize(q); Vector3 n = (Vector3)q.RotateVector3(Vector3.AxisZ); v.x += n.x * 2.5; v.z += n.z * 2.5; self.Playfield.Teleport( (Dynel)self, new Coordinate(v), q, new Identity() { Type = IdentityType.Playfield, Instance = externalPlayfieldId }); } return(door != null); }
public override bool Execute( INamedEntity self, IEntity caller, IInstancedEntity target, MessagePackObject[] arguments) { ICharacter character = (ICharacter)self; int statelId = (int)((uint)0xC0000000 | arguments[1].AsInt32() | (arguments[2].AsInt32() << 16)); character.Stats[StatIds.externaldoorinstance].BaseValue = 0; character.Stats[StatIds.externalplayfieldinstance].BaseValue = 0; if (arguments[1].AsInt32() > 0) { StatelData sd = PlayfieldLoader.PFData[arguments[1].AsInt32()].GetDoor(statelId); if (sd == null) { throw new Exception( "Statel " + arguments[3].AsInt32().ToString("X") + " not found? Check the rdb dammit"); } Vector3 v = new Vector3(sd.X, sd.Y, sd.Z); Quaternion q = new Quaternion(sd.HeadingX, sd.HeadingY, sd.HeadingZ, sd.HeadingW); Quaternion.Normalize(q); Vector3 n = (Vector3)q.RotateVector3(Vector3.AxisZ); v.x += n.x * 2.5; v.z += n.z * 2.5; character.Playfield.Teleport( (Dynel)character, new Coordinate(v), q, new Identity() { Type = (IdentityType)arguments[0].AsInt32(), Instance = arguments[1].AsInt32() }); } return true; self.Stats[StatIds.externalplayfieldinstance].Value = 0; self.Stats[StatIds.externaldoorinstance].Value = 0; self.Playfield.Teleport( (Dynel)self, new Coordinate(100, 10, 100), ((ICharacter)self).Heading, new Identity() { Type = (IdentityType)arguments[0].AsInt32(), Instance = arguments[1].AsInt32() }); return true; }
internal Coordinate CalculatePredictedPosition() { if ((this.moveDirection == MoveDirections.None) && (this.strafeDirection == SpinOrStrafeDirections.None)) { return(new Coordinate(this.RawCoordinates)); } else if (this.spinDirection == SpinOrStrafeDirections.None) { Vector3 moveVector = this.CalculateMoveVector(); moveVector = moveVector * this.PredictionDuration.TotalSeconds; /*this.RawCoordinates = new Vector3() * { * x = this.RawCoordinates.X + moveVector.x, * y = this.RawCoordinates.Y + moveVector.y, * z = this.RawCoordinates.Z + moveVector.z * }; * * this.PredictionTime = DateTime.UtcNow;*/ Coordinate result = new Coordinate( new Vector3( this.RawCoordinates.X + moveVector.x, this.RawCoordinates.Y + moveVector.y, this.RawCoordinates.Z + moveVector.z)); LogUtil.Debug( DebugInfoDetail.Movement, moveVector.ToString().PadRight(40) + "/" + result.ToString() + "/"); return(result); } else { Vector3 moveVector; Vector3 positionFromCentreOfTurningCircle; double turnArcAngle; double y; double duration; duration = this.PredictionDuration.TotalSeconds; moveVector = this.CalculateMoveVector(); turnArcAngle = this.calculateTurnArcAngle(); // This is calculated seperately as height is unaffected by turning y = this.RawCoordinates.Y + (moveVector.y * duration); if (this.spinDirection == SpinOrStrafeDirections.Left) { positionFromCentreOfTurningCircle = new Vector3(moveVector.z, y, -moveVector.x); } else { positionFromCentreOfTurningCircle = new Vector3(-moveVector.z, y, moveVector.x); } return (new Coordinate( new Vector3(this.RawCoordinates.X, this.RawCoordinates.Y, this.RawCoordinates.Z) + (Vector3) Quaternion.RotateVector3( new Quaternion(Vector3.AxisY, turnArcAngle), positionFromCentreOfTurningCircle) - positionFromCentreOfTurningCircle)); } }
public override bool Execute( INamedEntity self, IEntity caller, IInstancedEntity target, MessagePackObject[] arguments) { uint externalDoorInstance = self.Stats[StatIds.externaldoorinstance].BaseValue; int externalPlayfieldId = self.Stats[StatIds.externalplayfieldinstance].Value; StatelData door = PlayfieldLoader.PFData[externalPlayfieldId].Statels.FirstOrDefault( x => (uint)x.Identity.Instance == externalDoorInstance && (x.Identity.Type == IdentityType.Door /*|| x.Identity.Type==IdentityType.MissionEntrance*/)); if (door != null) { Vector3 v = new Vector3(door.X, door.Y, door.Z); Quaternion q = new Quaternion(door.HeadingX, door.HeadingY, door.HeadingZ, door.HeadingW); Quaternion.Normalize(q); Vector3 n = (Vector3)q.RotateVector3(Vector3.AxisZ); v.x += n.x * 2.5; v.z += n.z * 2.5; self.Playfield.Teleport( (Dynel)self, new Coordinate(v), q, new Identity() { Type = IdentityType.Playfield, Instance = externalPlayfieldId }); } return door != null; }