Exemplo n.º 1
0
 public static void RotateAround(BlockGroupEntity bge, int angle)
 {
     bge.Angle = (bge.Angle + angle) % 360;
     if (bge.Angle < 0)
     {
         bge.Angle += 360;
     }
     Location relpos = new Location(bge.shapeOffs.X, bge.shapeOffs.Y, 0);
     if (bge.Angle == 0)
     {
         bge.rotOffs = Location.Zero;
     }
     else if (bge.Angle == 90)
     {
         bge.rotOffs = new Location(-bge.shapeOffs.Y, bge.shapeOffs.X, 0) - relpos;
     }
     else if (bge.Angle == 180)
     {
         bge.rotOffs = new Location(-bge.shapeOffs.X, -bge.shapeOffs.Y, 0) - relpos;
     }
     else if (bge.Angle == 270)
     {
         bge.rotOffs = new Location(bge.shapeOffs.Y, -bge.shapeOffs.X, 0) - relpos;
     }
     else
     {
         bge.Angle = 0;
         bge.rotOffs = Location.Zero;
     }
     bge.SetOrientation(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (double)bge.Angle * (double)Utilities.PI180));
 }
Exemplo n.º 2
0
 // TODO: EFficiency needed so much!
 public override void Execute(PlayerCommandEntry entry)
 {
     if (entry.InputArguments.Count < 1)
     {
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "/blockship <convex/perfect> [scale]");
         return;
     }
     BGETraceMode tm = BGETraceMode.CONVEX;
     if (entry.InputArguments[0].ToLowerFast() == "perfect")
     {
         tm = BGETraceMode.PERFECT;
     }
     double maxRad = 20; // TODO: Config!
     Location start = (entry.Player.GetPosition() + new Location(0, 0, -0.1)).GetBlockLocation();
     List<KeyValuePair<Location, BlockInternal>> blocks = new List<KeyValuePair<Location, BlockInternal>>();
     AABB extent = new AABB() { Min = start, Max = start };
     if (!FloodFrom(entry.Player.TheRegion, start, blocks, maxRad, extent) || blocks.Count == 0)
     {
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Invalid flood-search!");
         return;
     }
     Location size = extent.Max - extent.Min;
     int xwidth = (int)size.X + 1;
     int ywidth = (int)size.Y + 1;
     int zwidth = (int)size.Z + 1;
     int xsub = (int)extent.Min.X;
     int ysub = (int)extent.Min.Y;
     int zsub = (int)extent.Min.Z;
     BlockInternal[] blocksin = new BlockInternal[xwidth * ywidth * zwidth];
     foreach (KeyValuePair<Location, BlockInternal> block in blocks)
     {
         entry.Player.TheRegion.SetBlockMaterial(block.Key, Material.AIR, 0, 0, 1, 0, true, true, true);
         blocksin[(int)(block.Key.Z - zsub) * ywidth * xwidth + (int)(block.Key.Y - ysub) * xwidth + (int)(block.Key.X - xsub)] = block.Value;
     }
     BlockGroupEntity bge = new BlockGroupEntity(extent.Min, tm, entry.Player.TheRegion, blocksin, xwidth, ywidth, zwidth);
     bge.scale = entry.InputArguments.Count < 2 ? Location.One : Location.FromString(entry.InputArguments[1]);
     entry.Player.TheRegion.SpawnEntity(bge);
 }
Exemplo n.º 3
0
 public BlockGroupEntityTag(BlockGroupEntity ent)
 {
     Internal = ent;
 }
Exemplo n.º 4
0
 public BlockGroupEntity ToBGE(Region tregion, Location pos)
 {
     BlockGroupEntity bge = new BlockGroupEntity(pos, BGETraceMode.PERFECT, tregion, Blocks, Size.X, Size.Y, Size.Z, new Location(Origin.X, Origin.Y, Origin.Z));
     bge.SetMass(0);
     bge.CGroup = CollisionUtil.NonSolid;
     bge.Color = System.Drawing.Color.FromArgb(160, 255, 255, 255);
     return bge;
 }