Esempio n. 1
0
        public override bool Execute(EntityPool pool, ExecutionContext ctx)
        {
            Int3 opCoords = TargetLocation.FloorInt3;

            if (ctx.LocalSpace.Contains(Origin.Position))
            {
                Entity e;
                if (!pool.Find(Origin.Guid, out e))
                {
                    return(false);
                }
                if (!ctx.CheckM("Motion", TargetLocation, e))
                {
                    return(false);
                }

                if (ctx.LocalSpace.Contains(TargetLocation))
                {
                    pool.ConflictFreeUpdateEntity(Origin, Entity);
                }
                else
                {
                    pool.ConflictFreeFindAndRemove(e.ID);
                }
                return(true);
            }
            else
            {
                if (!ctx.LocalSpace.Contains(TargetLocation))
                {
                    ctx.LogMessage("Motion: Shard coordinate mismatch. Local=" + ctx.LocalSpace + ", target=" + TargetLocation);
                    return(false);
                }
                if (!ctx.CheckM("Motion", Origin.Position, TargetLocation))
                {
                    return(false);
                }
                pool.ConflictFreeInsert(Origin, Entity);
                return(true);
            }
        }