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); } }
public override bool Execute(EntityPool pool, ExecutionContext ctx) { if (!ctx.CheckM("Insert", Origin.Position, TargetLocation)) { return(false); } if (!ctx.LocalSpace.Contains(TargetLocation)) { return(false); } pool.ConflictFreeInsert(Origin, new Entity(new EntityID(Guid.NewGuid(), TargetLocation), Vec3.Zero, directState, SerialLogic #if STATE_ADV , Appearances #endif )); directState = null; return(true); }
public override bool Execute(EntityPool pool, ExecutionContext ctx) { Vec3?loc; var rs = pool.CheckFindAndRemove(Target, e => ctx.CheckM("Removal", Target.Position, e), out loc); switch (rs) { case EntityPool.Result.NoError: return(true); case EntityPool.Result.IDNotFoundLocationMismatch: case EntityPool.Result.IDNotFound: case EntityPool.Result.VerificationFailed: return(false); //do not distinbuish. these errors could all be either caused by bad node states OR bad entity behavior default: throw new IntegrityViolation(Target + ": Unsupported CheckFindAndRemove() return value (" + rs + ")"); } }