Esempio n. 1
0
 public EntityPool(IEnumerable <Entity> entities, EntityChange.ExecutionContext ctx)
 {
     this.ctx = ctx;
     if (entities != null)
     {
         foreach (var e in entities)
         {
             var c = InsertC(e);
             if (c == null)
             {
                 ctx.LogMessage("Failed to insert entity " + e);
             }
         }
     }
 }
Esempio n. 2
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);
            }
        }