public static Matrix ToXna(this AFrame frame) { var translate = Matrix.CreateTranslation(frame.Origin.ToXna()); var rotate = Matrix.CreateFromQuaternion(frame.Orientation.ToXna()); return(rotate * translate); }
/// <summary> /// Starts rotating a creature from its current direction /// so that it eventually is facing the rotation from the input position /// Used by the emote system, which has the target rotation stored in positions /// </summary> /// <returns>The amount of time in seconds for the rotation to complete</returns> public float TurnTo(Position position) { var frame = new AFrame(position.Pos, position.Rotation); var heading = frame.get_heading(); // send network message to start turning creature var turnToMotion = new Motion(this, position, heading); EnqueueBroadcastMotion(turnToMotion); var angle = GetAngle(position); //Console.WriteLine("Angle: " + angle); // estimate time to rotate to target var rotateDelay = GetRotateDelay(angle); //Console.WriteLine("RotateTime: " + rotateTime); // update server object rotation on completion // TODO: proper incremental rotation var actionChain = new ActionChain(); actionChain.AddDelaySeconds(rotateDelay); actionChain.AddAction(this, () => { var targetDir = position.GetCurrentDir(); Location.Rotate(targetDir); PhysicsObj.Position.Frame.Orientation = Location.Rotation; }); actionChain.EnqueueChain(); return(rotateDelay); }
/// <summary> /// Sends a network message for moving a creature to a new position /// </summary> public void MoveTo(Position position, float runRate = 1.0f, bool setLoc = true, float? walkRunThreshold = null, float? speed = null) { // TODO: change parameters to accept an optional MoveToParameters var motion = new Motion(this, position); motion.MovementType = MovementType.MoveToPosition; //motion.Flag |= MovementParams.CanCharge | MovementParams.FailWalk | MovementParams.UseFinalHeading | MovementParams.MoveAway; if (walkRunThreshold != null) motion.MoveToParameters.WalkRunThreshold = walkRunThreshold.Value; if (speed != null) motion.MoveToParameters.Speed = speed.Value; // always use final heading? var frame = new AFrame(position.Pos, position.Rotation); motion.MoveToParameters.DesiredHeading = frame.get_heading(); motion.MoveToParameters.MovementParameters |= MovementParams.UseFinalHeading; motion.MoveToParameters.DistanceToObject = 0.6f; if (runRate > 0) motion.RunRate = runRate; else motion.MoveToParameters.MovementParameters &= ~MovementParams.CanRun; // todo: use better movement system // todo: set physics position if (setLoc) Location = new Position(position); EnqueueBroadcastMotion(motion); }
/// <summary> /// Sends a network message for moving a creature to a new position /// </summary> public void MoveTo(Position position, float runRate = 1.0f) { var motion = new Motion(this, position); motion.MovementType = MovementType.MoveToPosition; //motion.Flag |= MovementParams.CanCharge | MovementParams.FailWalk | MovementParams.UseFinalHeading | MovementParams.MoveAway; motion.MoveToParameters.WalkRunThreshold = 1.0f; // always use final heading? var frame = new AFrame(position.Pos, position.Rotation); motion.MoveToParameters.DesiredHeading = frame.get_heading(); motion.MoveToParameters.MovementParameters |= MovementParams.UseFinalHeading; motion.MoveToParameters.DistanceToObject = 0.6f; if (runRate > 0) { motion.RunRate = runRate; } else { motion.MoveToParameters.MovementParameters &= ~MovementParams.CanRun; } // todo: use better movement system Location = new Position(position); EnqueueBroadcastMotion(motion); }
public void UpdateParts(AFrame frame) { var curFrame = Sequence.GetCurrAnimFrame(); // modified for simple setups, or else only PhysicsObj.Position is set, // and PhysicsPart.Pos doesn't get set var numParts = Parts.Count; if (curFrame != null) { numParts = Math.Min(Parts.Count, curFrame.Frames.Count); } for (var i = 0; i < numParts; i++) { // should particles have this populated? if (Parts[i] == null) { continue; } var curPartFrame = curFrame != null ? new AFrame(curFrame.Frames[i]) : new AFrame(Vector3.Zero, Quaternion.Identity); Parts[i].Pos.Frame.Combine(frame, curPartFrame, Scale); if (Parts[i].Buffer != null) { Parts[i].Buffer.UpdateInstance(Parts[i].BufferIdx, Parts[i].Pos.GetWorldPos(), Parts[i].Pos.Frame.Orientation.ToXna(), Parts[i].GfxObjScale.ToXna()); } } }
public Motion GetMoveToPosition(Position position, float runRate = 1.0f, float?walkRunThreshold = null, float?speed = null) { // TODO: change parameters to accept an optional MoveToParameters var motion = new Motion(this, position); motion.MovementType = MovementType.MoveToPosition; //motion.Flag |= MovementParams.CanCharge | MovementParams.FailWalk | MovementParams.UseFinalHeading | MovementParams.MoveAway; if (walkRunThreshold != null) { motion.MoveToParameters.WalkRunThreshold = walkRunThreshold.Value; } if (speed != null) { motion.MoveToParameters.Speed = speed.Value; } // always use final heading? var frame = new AFrame(position.Pos, position.Rotation); motion.MoveToParameters.DesiredHeading = frame.get_heading(); motion.MoveToParameters.MovementParameters |= MovementParams.UseFinalHeading; motion.MoveToParameters.DistanceToObject = 0.6f; if (runRate > 0) { motion.RunRate = runRate; } else { motion.MoveToParameters.MovementParameters &= ~MovementParams.CanRun; } return(motion); }
public void MoveWeeniePiece(BasePiece piece) { var gamePiece = ChessBoard.CurrentLandblock.GetObject(piece.Guid) as GamePiece; if (gamePiece == null) { Console.WriteLine($"ChessMatch.MoveWeeniePiece({piece.Guid.Full:X8}): couldn't find game piece"); DebugMove(); Logic.DebugBoard(); return; } var frame = new AFrame(ChessBoard.PhysicsObj.Position.Frame); CalculateWeeniePosition(piece.Coord, piece.Color, frame); var position = new Position(ChessBoard.Location); position.Pos = frame.Origin; position.Rotation = frame.Orientation; gamePiece.MoveEnqueue(position); AddPendingWeenieMotion(piece); }
public ShadowPart(int numPlanes, List <int> planes, AFrame frame, PhysicsPart part) { NumPlanes = numPlanes; Planes = planes; Frame = frame; Part = part; }
public ShadowPart(List <int> planes, AFrame frame, PhysicsPart part) { NumPlanes = planes != null ? planes.Count : 0; Planes = planes; Frame = frame; Part = part; }
public void AddChild(PhysicsObj obj, AFrame frame, int partIdx, int locationID) { Objects.Add(obj); Frames.Add(frame); PartNumbers.Add(partIdx); LocationIDs.Add(locationID); NumObjects++; }
public ParticleEmitter(PhysicsObj parent) { Parent = parent; PartIndex = -1; ParentOffset = new AFrame(); LastUpdateTime = PhysicsTimer.CurrentTime; LastEmitTime = PhysicsTimer.CurrentTime; }
public void CalculateWeeniePosition(ChessPieceCoord coord, ChessColor color, AFrame frame) { var heading = (uint)ChessBoard.PhysicsObj.Position.Frame.get_heading(); heading += color == ChessColor.Black ? 180u : 0u; heading %= 360; frame.Origin += new Vector3(coord.X - 3.5f, coord.Y - 3.5f, 0.0f); frame.set_heading(heading); }
public bool SetParenting(int partIdx, AFrame frame) { if (PhysicsObj == null || !PhysicsObj.set_parent(Parent, partIdx, frame)) { return(false); } PartIndex = partIdx; ParentOffset = new AFrame(frame); return(true); }
/// <summary> /// Aligns an object to a plane /// </summary> public static AFrame ObjAlign(DatLoader.Entity.ObjectDesc obj, Plane plane, Vector3 loc) { var frame = new AFrame(obj.BaseLoc); frame.Origin = loc; var negNormal = -plane.Normal; var degrees = negNormal.get_heading(); frame.set_heading(degrees); return(frame); }
public Position(Position p) { if (p == null) { Console.WriteLine("Position copy constructor - null"); Frame = new AFrame(); return; } ObjCellID = p.ObjCellID; Frame = new AFrame(p.Frame); }
/// <summary> /// Returns the rotation for a scenery object /// </summary> public static AFrame RotateObj(DatLoader.Entity.ObjectDesc obj, uint x, uint y, uint k, Vector3 loc) { var frame = new AFrame(obj.BaseLoc); frame.Origin = loc; if (obj.MaxRotation > 0.0f) { var degrees = (float)((1813693831 * y - (k + 63127) * (1360117743 * y * x + 1888038839) - 1109124029 * x) * 2.3283064e-10 * obj.MaxRotation); frame.set_heading(degrees); } return(frame); }
public void InitEmitter(List <uint> emitterInfoIDs, float mod = 0.0f) { GameView.ViewMode = ViewMode.Particle; foreach (var emitterInfoID in emitterInfoIDs) { var emitterInfo = DatManager.PortalDat.ReadFromDat <ACE.DatLoader.FileTypes.ParticleEmitterInfo>(emitterInfoID); MainWindow.Status.WriteLine($"ParticleEmitterInfo.ID: {emitterInfoID:X8}"); var frame = new AFrame(); Player.PhysicsObj.create_particle_emitter(emitterInfoID, 0, frame, 0); } }
public void UpdateSettings(Settings settings, UpdatePhase phase) { if (phase == UpdatePhase.TempSettingsLoaded) { if (settingsSize != null && !settingsSize.changed) { size = settingsSize.value; } } if (AFrame != null) { AFrame.UpdateSettings(settings, phase); } }
public void AddWeeniePiece(BasePiece piece) { var frame = new AFrame(ChessBoard.PhysicsObj.Position.Frame); CalculateWeeniePosition(piece.Coord, piece.Color, frame); var monster = piece.Color == ChessColor.Black ? "drudge" : "mosswart"; var weeniename = ""; switch (piece.Type) { case ChessPieceType.Pawn: weeniename = $"{monster}pawn"; break; case ChessPieceType.Rook: weeniename = $"{monster}rook"; break; case ChessPieceType.Knight: weeniename = $"{monster}knight"; break; case ChessPieceType.Bishop: weeniename = $"{monster}bishop"; break; case ChessPieceType.Queen: weeniename = $"{monster}queen"; break; case ChessPieceType.King: weeniename = $"{monster}king"; break; } var wo = WorldObjectFactory.CreateNewWorldObject(weeniename); //Console.WriteLine($"AddWeeniePiece: {weeniename}, {piece.Coord}, {frame.Origin}"); // add to position, spawn wo.Location = new Position(ChessBoard.Location); wo.Location.Pos = frame.Origin; wo.Location.Rotation = frame.Orientation; wo.EnterWorld(); piece.Guid = wo.Guid; (wo as GamePiece).ChessMatch = this; }
public void AddPart(PhysicsPart part, List <int> planes, AFrame frame, int numShadowParts) { return; /*if (part == null) return; * * var shadowPart = new ShadowPart(); * if (planes != null) * shadowPart = new ShadowPart(1, planes, frame, part); * else * shadowPart = new ShadowPart(null, null, part); * * ShadowPartList.Add(shadowPart);*/ }
public void UpdateParts(AFrame frame) { var curFrame = Sequence.GetCurrAnimFrame(); if (curFrame == null) { return; } var numParts = Math.Min(curFrame.Frames.Count, NumParts); // first numparts? for (var i = 0; i < numParts; i++) { Parts[i].Pos.Frame = AFrame.Combine(frame, new AFrame(curFrame.Frames[i]), Scale); } }
public void Destroy() { if (owner == null) { return; } if (AFrame != null) { AFrame.Destroy(); } removeNest(this); mainForm = null; owner = null; }
public void AddPart(PhysicsPart part, List <int> planes, AFrame frame, int numShadowParts) { var shadowPart = new ShadowPart(); if (planes != null) { shadowPart = new ShadowPart(1, planes, frame, part); } else { shadowPart = new ShadowPart(null, null, part); } ShadowPartList.Add(shadowPart); NumShadowParts++; }
/// <summary> /// Sends a network message for moving a creature to a new position /// </summary> public void MoveTo(Position position, float runRate = 1.0f, bool setLoc = true, float?walkRunThreshold = null, float?speed = null) { // TODO: change parameters to accept an optional MoveToParameters var motion = new Motion(this, position); motion.MovementType = MovementType.MoveToPosition; //motion.Flag |= MovementParams.CanCharge | MovementParams.FailWalk | MovementParams.UseFinalHeading | MovementParams.MoveAway; if (walkRunThreshold != null) { motion.MoveToParameters.WalkRunThreshold = walkRunThreshold.Value; } if (speed != null) { motion.MoveToParameters.Speed = speed.Value; } // always use final heading? var frame = new AFrame(position.Pos, position.Rotation); motion.MoveToParameters.DesiredHeading = frame.get_heading(); motion.MoveToParameters.MovementParameters |= MovementParams.UseFinalHeading; motion.MoveToParameters.DistanceToObject = 0.6f; if (runRate > 0) { motion.RunRate = runRate; } else { motion.MoveToParameters.MovementParameters &= ~MovementParams.CanRun; } // todo: use physics MoveToManager // todo: handle landblock updates if (setLoc) { Location = new Position(position); PhysicsObj.SetPositionSimple(new Physics.Common.Position(position), true); } EnqueueBroadcastMotion(motion); }
public void UpdateParts(AFrame frame) { var animFrame = Sequence.GetCurrAnimFrame(); if (animFrame == null) { return; } var numParts = NumParts; if (numParts > animFrame.NumParts) { numParts = animFrame.NumParts; } for (var i = 0; i < numParts; i++) { Parts[i].Pos.Frame.Combine(frame, animFrame.Frame[i], Scale); } }
/// <summary> /// Returns the splatter direction quadrant string /// </summary> public string GetSplatterDir(WorldObject target) { var sourcePos = new Vector3(Location.PositionX, Location.PositionY, 0); var targetPos = new Vector3(target.Location.PositionX, target.Location.PositionY, 0); var targetDir = new AFrame(target.Location.Pos, target.Location.Rotation).get_vector_heading(); targetDir.Z = 0; targetDir = Vector3.Normalize(targetDir); var sourceToTarget = Vector3.Normalize(sourcePos - targetPos); var dir = Vector3.Dot(sourceToTarget, targetDir); var angle = Vector3.Cross(sourceToTarget, targetDir); var frontBack = dir >= 0 ? "Front" : "Back"; var leftRight = angle.Z <= 0 ? "Left" : "Right"; return(leftRight + frontBack); }
public void UpdateParts(AFrame frame) { var curFrame = Sequence.GetCurrAnimFrame(); if (curFrame == null) { if (Parts.Count == 1) { Parts[0].Pos = Owner.Position; } return; } var numParts = Math.Min(NumParts, curFrame.Frames.Count); for (var i = 0; i < numParts; i++) { Parts[i].Pos.Frame.Combine(frame, new AFrame(curFrame.Frames[i]), Scale); } }
public void AttackWeeniePiece(BasePiece piece, ObjectGuid victim) { var gamePiece = ChessBoard.CurrentLandblock.GetObject(piece.Guid) as GamePiece; if (gamePiece == null) { DebugMove(); Logic.DebugBoard(); } Debug.Assert(gamePiece != null); var frame = new AFrame(ChessBoard.PhysicsObj.Position.Frame); CalculateWeeniePosition(piece.Coord, piece.Color, frame); var position = new Position(ChessBoard.Location); position.Pos = frame.Origin; position.Rotation = frame.Orientation; gamePiece.AttackEnqueue(position, victim); AddPendingWeenieMotion(piece); }
public void Init() { Frame = new AFrame(); }
public Position(ACE.Entity.Position p) { ObjCellID = p.Cell; Frame = new AFrame(p.Pos, p.Rotation); }