public Position3D Rotate(Direction dir) { Position3D p = new Position3D(); p.X = dir.Shift(1) * X + dir.Shift(0) * Z; p.Y = 0; p.Z = dir.Shift(1) * Z + dir.Shift(3) * X; return p; }
public Position3D Offset(Position3D p) { return new Position3D(X + p.X, Y + p.Y, Z + p.Z); }
public bool CanPassThrough(Position3D pos) { Model b = this[pos]; return b == null || !b.Template.IsCollidable; }
public void SetPosition(Position3D pos) { position = pos; }
public void AddModel(Model Model, Position3D location) { PlaceModel(Model, location); Children.Add(Model); }
public void PlaceModel(Model model, Position3D location) { // Set new location (for visual update) model.Position = location; // Set new area location.ForEachInRange(model.Template.Dimension, (l) => { Model m = this[l]; if (m != null) { // Remove object being replaced RemoveModel(m); } this[l] = model; }); }
public void MoveModelTo(Model model, Position3D location) { ClearModel(model); PlaceModel(model, location); }
public Model this[Position3D location] { get { return models[location.X, location.Y, location.Z]; } set { models[location.X, location.Y, location.Z] = value; } }
private bool CanMove() { if (Actor.Movement == null) Actor.Movement = this; else if (Actor.Movement != this) return false; Position3D offset = Template.PositionOffset; if (Template.FollowDirection) offset = offset.Rotate(Actor.Direction); pos = Actor.Position.Offset(offset); // TODO: Test actor Model m = Game.Scene[pos]; if (m != null) { // Raise event whenever there's something ahead Event.Raise(m, Model.Collided); // Don't go if it collidable (or you will get hit!) if (m.Template.IsCollidable) return false; } dir = Actor.Direction.Offset(Template.DirectionOffset); return true; }