示例#1
0
        public override Entity Create(Region tregion, BsonDocument doc)
        {
            ModelEntity ent = new ModelEntity(doc["mod_name"].AsString, tregion);

            ent.mode   = (ModelCollisionMode)Enum.Parse(typeof(ModelCollisionMode), doc["mod_mode"].AsString);
            ent.CanLOD = doc["mod_lod"].AsBoolean;
            ent.ApplyPhysicsData(doc);
            return(ent);
        }
示例#2
0
 public LODModelPacketOut(ModelEntity me)
 {
     UsageType = NetUsageType.ENTITIES;
     ID = ServerToClientPacket.LOD_MODEL;
     Data = new byte[24 + 4 + 16 + 8 + 24];
     me.GetPosition().ToDoubleBytes().CopyTo(Data, 0);
     int ind = me.TheServer.Networking.Strings.IndexForString(me.model);
     Utilities.IntToBytes(ind).CopyTo(Data, 24);
     Quaternion quat = me.GetOrientation();
     Utilities.FloatToBytes((float)quat.X).CopyTo(Data, 24 + 4);
     Utilities.FloatToBytes((float)quat.Y).CopyTo(Data, 24 + 4 + 4);
     Utilities.FloatToBytes((float)quat.Z).CopyTo(Data, 24 + 4 + 4 + 4);
     Utilities.FloatToBytes((float)quat.W).CopyTo(Data, 24 + 4 + 4 + 4 + 4);
     Utilities.LongToBytes(me.EID).CopyTo(Data, 24 + 4 + 16);
     me.scale.ToDoubleBytes().CopyTo(Data, 24 + 4 + 16 + 8);
 }
示例#3
0
 public override void SpawnBody()
 {
     base.SpawnBody();
     if (CursorMarker == null)
     {
         CursorMarker         = new ModelEntity("cube", TheRegion);
         CursorMarker.scale   = new Location(0.1f, 0.1f, 0.1f);
         CursorMarker.mode    = ModelCollisionMode.AABB;
         CursorMarker.CGroup  = CollisionUtil.NonSolid;
         CursorMarker.Visible = false;
         CursorMarker.CanSave = false;
         TheRegion.SpawnEntity(CursorMarker);
     }
     Jetpack = new JetpackMotionConstraint(this);
     TheRegion.PhysicsWorld.Add(Jetpack);
 }
示例#4
0
        public void OnCollide(object sender, CollisionEventArgs args)
        {
            if (Stuck)
            {
                return;
            }
            double len = GetVelocity().Length();

            SetPosition(args.Info.Position + (GetVelocity() / len) * 0.05f);
            SetVelocity(Location.Zero);
            Gravity = Location.Zero;
            if (HasHat)
            {
                SolidHat = new ModelEntity("invisbox", TheRegion);
                SolidHat.SetMass(0);
                SolidHat.SetPosition(GetPosition());
                SolidHat.SetOrientation(GetOrientation());
                SolidHat.scale   = new Location(0.6, 1.5, 0.6);
                SolidHat.Visible = false;
                SolidHat.CanSave = false;
                TheRegion.SpawnEntity(SolidHat);
            }
            if (args.Info.HitEnt != null)
            {
                PhysicsEntity pe = (PhysicsEntity)args.Info.HitEnt.Tag;
                if (pe is EntityDamageable)
                {
                    ((EntityDamageable)pe).Damage(Damage + DamageTimesVelocity * (double)len);
                }
                Vector3 loc     = (args.Info.Position - pe.GetPosition()).ToBVector();
                Vector3 impulse = GetVelocity().ToBVector() * DamageTimesVelocity / 1000f;
                pe.Body.ApplyImpulse(ref loc, ref impulse);
                StuckTo = pe;
                if (HasHat)
                {
                    CollisionRules.AddRule(pe.Body, SolidHat.Body, CollisionRule.NoBroadPhase); // TODO: Broadcast this info! Perhaps abuse the joint system?
                }
            }
            TheRegion.SendToAll(new PrimitiveEntityUpdatePacketOut(this));
            if (args.Info.HitEnt != null)
            {
                PhysicsEntity  pe  = (PhysicsEntity)args.Info.HitEnt.Tag;
                JointForceWeld jfw = new JointForceWeld(pe, this);
                TheRegion.AddJoint(jfw);
            }
        }
示例#5
0
 public override void DestroyBody()
 {
     if (CBody == null)
     {
         return;
     }
     if (Jetpack != null)
     {
         TheRegion.PhysicsWorld.Remove(Jetpack);
         Jetpack = null;
     }
     base.DestroyBody();
     if (CursorMarker.IsSpawned && !CursorMarker.Removed)
     {
         CursorMarker.RemoveMe();
         CursorMarker = null;
     }
 }
示例#6
0
 public void SpawnTree(string tree, Location opos, Chunk chunk)
 {
     // TODO: Efficiency!
     ModelEntity me = new ModelEntity("plants/trees/" + tree, this);
     Location pos = opos + new Location(0, 0, 1);
     /*RayCastResult rcr;
     bool h = SpecialCaseRayTrace(pos, -Location.UnitZ, 50, MaterialSolidity.FULLSOLID, IgnoreEntities, out rcr);
     me.SetPosition(h ? new Location(rcr.HitData.Location) : pos);*/
     Vector3 treealign = new Vector3(0, 0, 1);
     Vector3 norm = /*h ? rcr.HitData.Normal : */new Vector3(0, 0, 1);
     Quaternion orient;
     Quaternion.GetQuaternionBetweenNormalizedVectors(ref treealign, ref norm, out orient);
     orient *= Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (double)(Utilities.UtilRandom.NextDouble() * Math.PI * 2));
     me.SetOrientation(orient);
     me.SetPosition(pos);
     me.CanLOD = true;
     me.GenBlockShadow = true;
     Action res = () =>
     {
         SpawnEntity(me);
         me.SetPosition(pos - new Location(norm) - new Location(Quaternion.Transform(me.offset.ToBVector(), orient)));
         me.ForceNetwork();
     };
     if (chunk == null)
     {
         res.Invoke();
     }
     else
     {
         chunk.fixesToRun.Add(TheWorld.Schedule.GetSyncTask(res));
     }
 }
示例#7
0
 public void ApplyHook(PlayerEntity player, ItemStack item, Location Position, BEPUphysics.Entities.Entity HitEnt)
 {
     RemoveHook(player);
     PhysicsEntity pe;
     double len = (double)(Position - player.GetCenter()).Length();
     Location step = (player.GetCenter() - Position) / len;
     Location forw = Utilities.VectorToAngles(step);
     BEPUutilities.Quaternion quat = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), (double)(forw.Pitch * Utilities.PI180)) *
         Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), (double)(forw.Yaw * Utilities.PI180));
     if (HitEnt == null)
     {
         ModelEntity mod = new ModelEntity("cube", player.TheRegion);
         mod.Mass = 0;
         mod.CanSave = false;
         mod.scale = new Location(0.023, 0.05, 0.05);
         mod.mode = ModelCollisionMode.AABB;
         mod.SetPosition(Position);
         mod.SetOrientation(quat);
         player.TheRegion.SpawnEntity(mod);
         pe = mod;
         player.Hooks.Add(new HookInfo() { Joint = null, Hit = pe, IsBar = true });
     }
     else
     {
         pe = (PhysicsEntity)HitEnt.Tag;
     }
     JointDistance jd;
     //jd = new JointDistance(player, pe, 0.01f, len + 0.01f, player.GetCenter(), Position);
     //player.TheRegion.AddJoint(jd);
     //player.Hooks.Add(new HookInfo() { Joint = jd, Hit = pe, IsBar = false });
     PhysicsEntity cent = pe;
     for (double f = 0; f < len - 1f; f += 0.5f)
     {
         Location cpos = Position + step * f;
         ModelEntity ce = new ModelEntity("cube", player.TheRegion);
         ce.Mass = 15;
         ce.CanSave = false;
         ce.scale = new Location(0.023, 0.05, 0.05);
         ce.mode = ModelCollisionMode.AABB;
         ce.SetPosition(cpos + step * 0.5);
         ce.SetOrientation(quat);
         player.TheRegion.SpawnEntity(ce);
         jd = new JointDistance(ce, cent, 0.01f, 0.5f, ce.GetPosition(), (ReferenceEquals(cent, pe) ? Position: cent.GetPosition()));
         CollisionRules.AddRule(player.Body, ce.Body, CollisionRule.NoBroadPhase);
         player.TheRegion.AddJoint(jd);
         player.Hooks.Add(new HookInfo() { Joint = jd, Hit = ce, IsBar = true });
         cent = ce;
     }
     jd = new JointDistance(cent, player, 0.01f, 0.5f, cent.GetPosition(), player.GetCenter());
     player.TheRegion.AddJoint(jd);
     player.Hooks.Add(new HookInfo() { Joint = jd, Hit = player, IsBar = false });
 }
示例#8
0
 public override void SpawnBody()
 {
     base.SpawnBody();
     if (CursorMarker == null)
     {
         CursorMarker = new ModelEntity("cube", TheRegion);
         CursorMarker.scale = new Location(0.1f, 0.1f, 0.1f);
         CursorMarker.mode = ModelCollisionMode.AABB;
         CursorMarker.CGroup = CollisionUtil.NonSolid;
         CursorMarker.Visible = false;
         CursorMarker.CanSave = false;
         TheRegion.SpawnEntity(CursorMarker);
     }
     Jetpack = new JetpackMotionConstraint(this);
     TheRegion.PhysicsWorld.Add(Jetpack);
 }
示例#9
0
 public override void DestroyBody()
 {
     if (CBody == null)
     {
         return;
     }
     if (Jetpack != null)
     {
         TheRegion.PhysicsWorld.Remove(Jetpack);
         Jetpack = null;
     }
     base.DestroyBody();
     if (CursorMarker.IsSpawned && !CursorMarker.Removed)
     {
         CursorMarker.RemoveMe();
         CursorMarker = null;
     }
 }
示例#10
0
 public void OnCollide(object sender, CollisionEventArgs args)
 {
     if (Stuck)
     {
         return;
     }
     double len = GetVelocity().Length();
     SetPosition(args.Info.Position + (GetVelocity() / len) * 0.05f);
     SetVelocity(Location.Zero);
     Gravity = Location.Zero;
     if (HasHat)
     {
         SolidHat = new ModelEntity("invisbox", TheRegion);
         SolidHat.SetMass(0);
         SolidHat.SetPosition(GetPosition());
         SolidHat.SetOrientation(GetOrientation());
         SolidHat.scale = new Location(0.6, 1.5, 0.6);
         SolidHat.Visible = false;
         SolidHat.CanSave = false;
         TheRegion.SpawnEntity(SolidHat);
     }
     if (args.Info.HitEnt != null)
     {
         PhysicsEntity pe = (PhysicsEntity)args.Info.HitEnt.Tag;
         if (pe is EntityDamageable)
         {
             ((EntityDamageable)pe).Damage(Damage + DamageTimesVelocity * (double)len);
         }
         Vector3 loc = (args.Info.Position - pe.GetPosition()).ToBVector();
         Vector3 impulse = GetVelocity().ToBVector() * DamageTimesVelocity / 1000f;
         pe.Body.ApplyImpulse(ref loc, ref impulse);
         StuckTo = pe;
         if (HasHat)
         {
             CollisionRules.AddRule(pe.Body, SolidHat.Body, CollisionRule.NoBroadPhase); // TODO: Broadcast this info! Perhaps abuse the joint system?
         }
     }
     TheRegion.SendToAll(new PrimitiveEntityUpdatePacketOut(this));
     if (args.Info.HitEnt != null)
     {
         PhysicsEntity pe = (PhysicsEntity)args.Info.HitEnt.Tag;
         JointForceWeld jfw = new JointForceWeld(pe, this);
         TheRegion.AddJoint(jfw);
     }
 }
示例#11
0
 public ModelEntityTag(ModelEntity ent)
 {
     Internal = ent;
 }
示例#12
0
 public override void Execute(PlayerCommandEntry entry)
 {
     if (entry.InputArguments.Count <= 0)
     {
         ShowUsage(entry);
         return;
     }
     string arg0 = entry.InputArguments[0];
     if (arg0 == "spawnCar" && entry.InputArguments.Count > 1)
     {
         CarEntity ve = new CarEntity(entry.InputArguments[1], entry.Player.TheRegion);
         ve.SetPosition(entry.Player.GetEyePosition() + entry.Player.ForwardVector() * 5);
         entry.Player.TheRegion.SpawnEntity(ve);
     }
     else if (arg0 == "spawnHeli" && entry.InputArguments.Count > 1)
     {
         HelicopterEntity ve = new HelicopterEntity(entry.InputArguments[1], entry.Player.TheRegion);
         ve.SetPosition(entry.Player.GetEyePosition() + entry.Player.ForwardVector() * 5);
         entry.Player.TheRegion.SpawnEntity(ve);
     }
     else if (arg0 == "spawnPlane" && entry.InputArguments.Count > 1)
     {
         PlaneEntity ve = new PlaneEntity(entry.InputArguments[1], entry.Player.TheRegion);
         ve.SetPosition(entry.Player.GetEyePosition() + entry.Player.ForwardVector() * 5);
         entry.Player.TheRegion.SpawnEntity(ve);
     }
     else if (arg0 == "heloTilt" && entry.InputArguments.Count > 1)
     {
         if (entry.Player.CurrentSeat != null && entry.Player.CurrentSeat.SeatHolder is HelicopterEntity)
         {
             ((HelicopterEntity)entry.Player.CurrentSeat.SeatHolder).TiltMod = Utilities.StringToFloat(entry.InputArguments[1]);
         }
     }
     else if (arg0 == "shortRange")
     {
         entry.Player.ViewRadiusInChunks = 3;
         entry.Player.ViewRadExtra2 = 0;
         entry.Player.ViewRadExtra2Height = 0;
         entry.Player.ViewRadExtra5 = 0;
         entry.Player.ViewRadExtra5Height = 0;
     }
     else if (arg0 == "fly")
     {
         if (entry.Player.IsFlying)
         {
             entry.Player.Unfly();
             entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Unflying!");
         }
         else
         {
             entry.Player.Fly();
             entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Flying!");
         }
     }
     else if (arg0 == "playerDebug")
     {
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "YOU: " + entry.Player.Name + ", tractionForce: " + entry.Player.CBody.TractionForce
              + ", mass: " + entry.Player.CBody.Body.Mass + ", radius: " + entry.Player.CBody.BodyRadius + ", hasSupport: " + entry.Player.CBody.SupportFinder.HasSupport
              + ", hasTraction: " + entry.Player.CBody.SupportFinder.HasTraction + ", isAFK: " + entry.Player.IsAFK + ", timeAFK: " + entry.Player.TimeAFK);
     }
     else if (arg0 == "playBall")
     {
         // TODO: Item for this?
         ModelEntity me = new ModelEntity("sphere", entry.Player.TheRegion);
         me.SetMass(5);
         me.SetPosition(entry.Player.GetCenter() + entry.Player.ForwardVector());
         me.mode = ModelCollisionMode.SPHERE;
         me.SetVelocity(entry.Player.ForwardVector());
         me.SetBounciness(0.95f);
         entry.Player.TheRegion.SpawnEntity(me);
     }
     else if (arg0 == "playDisc")
     {
         // TODO: Item for this?
         ModelEntity me = new ModelEntity("flyingdisc", entry.Player.TheRegion);
         me.SetMass(5);
         me.SetPosition(entry.Player.GetCenter() + entry.Player.ForwardVector() * 1.5f); // TODO: 1.5 -> 'reach' value?
         me.mode = ModelCollisionMode.AABB;
         me.SetVelocity(entry.Player.ForwardVector() * 25f); // TODO: 25 -> 'strength' value?
         me.SetAngularVelocity(new Location(0, 0, 10));
         entry.Player.TheRegion.SpawnEntity(me);
         entry.Player.TheRegion.AddJoint(new JointFlyingDisc(me));
     }
     else if (arg0 == "secureMovement")
     {
         entry.Player.SecureMovement = !entry.Player.SecureMovement;
         entry.Player.SendLanguageData(TextChannel.COMMAND_RESPONSE, "voxalia", "commands.player.devel.secure_movement", entry.Player.Network.GetLanguageData("voxalia", "common." + (entry.Player.SecureMovement ? "true" : "false")));
         if (entry.Player.SecureMovement)
         {
             entry.Player.Flags &= ~YourStatusFlags.INSECURE_MOVEMENT;
         }
         else
         {
             entry.Player.Flags |= YourStatusFlags.INSECURE_MOVEMENT;
         }
         entry.Player.SendStatus();
     }
     else if (arg0 == "chunkDebug")
     {
         Biome biome;
         Location posBlock = entry.Player.GetPosition().GetBlockLocation();
         double h = entry.Player.TheRegion.Generator.GetHeight(entry.Player.TheRegion.TheWorld.Seed, entry.Player.TheRegion.TheWorld.Seed2, entry.Player.TheRegion.TheWorld.Seed3,
             entry.Player.TheRegion.TheWorld.Seed4, entry.Player.TheRegion.TheWorld.Seed5, (double)posBlock.X, (double)posBlock.Y, (double)posBlock.Z, out biome);
         BlockInternal bi = entry.Player.TheRegion.GetBlockInternal_NoLoad((entry.Player.GetPosition() + new Location(0, 0, -0.05f)).GetBlockLocation());
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Mat: " + bi.Material + ", data: " + ((int)bi.BlockData) + ", locDat: " + ((int)bi.BlockLocalData)
             + ", Damage: " + bi.Damage + ", Paint: " + bi.BlockPaint
             + ", xp: " + BlockShapeRegistry.BSD[bi.BlockData].OccupiesXP() + ", xm: " + BlockShapeRegistry.BSD[bi.BlockData].OccupiesXM()
             + ", yp: " + BlockShapeRegistry.BSD[bi.BlockData].OccupiesYP() + ", ym: " + BlockShapeRegistry.BSD[bi.BlockData].OccupiesYM()
             + ", zp: " + BlockShapeRegistry.BSD[bi.BlockData].OccupiesTOP() + ", zm: " + BlockShapeRegistry.BSD[bi.BlockData].OccupiesBOTTOM());
         double temp = entry.Player.TheRegion.BiomeGen.GetTemperature(entry.Player.TheRegion.TheWorld.Seed2, entry.Player.TheRegion.TheWorld.Seed3, (double)posBlock.X, (double)posBlock.Y);
         double down = entry.Player.TheRegion.BiomeGen.GetDownfallRate(entry.Player.TheRegion.TheWorld.Seed3, entry.Player.TheRegion.TheWorld.Seed4, (double)posBlock.X, (double)posBlock.Y);
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Height: " + h + ", temperature: " + temp + ", downfallrate: " + down + ", biome yield: " + biome.GetName());
     }
     else if (arg0 == "structureSelect" && entry.InputArguments.Count > 1)
     {
         string arg1 = entry.InputArguments[1];
         entry.Player.Items.GiveItem(new ItemStack("structureselector", arg1, entry.Player.TheServer, 1, "items/admin/structure_selector",
             "Structure Selector", "Selects and creates a '" + arg1 + "' structure!", System.Drawing.Color.White, "items/admin/structure_selector", false, 0));
     }
     else if (arg0 == "structureCreate" && entry.InputArguments.Count > 1)
     {
         string arg1 = entry.InputArguments[1];
         entry.Player.Items.GiveItem(new ItemStack("structurecreate", arg1, entry.Player.TheServer, 1, "items/admin/structure_create",
             "Structure Creator", "Creates a '" + arg1 + "' structure!", System.Drawing.Color.White, "items/admin/structure_create", false, 0));
     }
     else if (arg0 == "musicBlock" && entry.InputArguments.Count > 3)
     {
         int arg1 = Utilities.StringToInt(entry.InputArguments[1]);
         double arg2 = Utilities.StringToFloat(entry.InputArguments[2]);
         double arg3 = Utilities.StringToFloat(entry.InputArguments[3]);
         entry.Player.Items.GiveItem(new ItemStack("customblock", entry.Player.TheServer, 1, "items/custom_blocks/music_block",
             "Music Block", "Plays music!", System.Drawing.Color.White, "items/custom_blocks/music_block", false, 0,
             new KeyValuePair<string, TemplateObject>("music_type", new IntegerTag(arg1)),
             new KeyValuePair<string, TemplateObject>("music_volume", new NumberTag(arg2)),
             new KeyValuePair<string, TemplateObject>("music_pitch", new NumberTag(arg3)))
         {
             Datum = new BlockInternal((ushort)Material.DEBUG, 0, 0, 0).GetItemDatum()
         });
     }
     else if (arg0 == "structurePaste" && entry.InputArguments.Count > 1)
     {
         string arg1 = entry.InputArguments[1];
         entry.Player.Items.GiveItem(new ItemStack("structurepaste", arg1, entry.Player.TheServer, 1, "items/admin/structure_paste",
             "Structor Paster", "Pastes a ;" + arg1 + "; structure!", System.Drawing.Color.White, "items/admin/structure_paste", false, 0));
     }
     else if (arg0 == "testPerm" && entry.InputArguments.Count > 1)
     {
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Testing " + entry.InputArguments[1] + ": " + entry.Player.HasPermission(entry.InputArguments[1]));
     }
     else if (arg0 == "spawnTree" && entry.InputArguments.Count > 1)
     {
         entry.Player.TheRegion.SpawnTree(entry.InputArguments[1].ToLowerFast(), entry.Player.GetPosition(), null);
     }
     else if (arg0 == "spawnTarget")
     {
         TargetEntity te = new TargetEntity(entry.Player.TheRegion);
         te.SetPosition(entry.Player.GetPosition() + entry.Player.ForwardVector() * 5);
         te.TheRegion.SpawnEntity(te);
     }
     else if (arg0 == "spawnSlime" && entry.InputArguments.Count > 2)
     {
         SlimeEntity se = new SlimeEntity(entry.Player.TheRegion, Utilities.StringToFloat(entry.InputArguments[2]));
         se.mod_color = ColorTag.For(entry.InputArguments[1]).Internal;
         se.SetPosition(entry.Player.GetPosition() + entry.Player.ForwardVector() * 5);
         se.TheRegion.SpawnEntity(se);
     }
     else if (arg0 == "timePathfind" && entry.InputArguments.Count > 1)
     {
         double dist = Utilities.StringToDouble(entry.InputArguments[1]);
         entry.Player.TheServer.Schedule.StartASyncTask(() =>
         {
             Stopwatch sw = new Stopwatch();
             sw.Start();
             List<Location> locs = entry.Player.TheRegion.FindPath(entry.Player.GetPosition(), entry.Player.GetPosition() + new Location(dist, 0, 0), dist * 2, 1.5f, true);
             sw.Stop();
             entry.Player.TheRegion.TheWorld.Schedule.ScheduleSyncTask(() =>
             {
                 if (locs != null)
                 {
                     entry.Player.Network.SendPacket(new PathPacketOut(locs));
                 }
                 entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Took " + sw.ElapsedMilliseconds + "ms, passed: " + (locs != null));
             });
         });
     }
     else if (arg0 == "findPath")
     {
         Location eye = entry.Player.GetEyePosition();
         Location forw = entry.Player.ForwardVector();
         Location goal;
         RayCastResult rcr;
         if (entry.Player.TheRegion.SpecialCaseRayTrace(eye, forw, 150, MaterialSolidity.FULLSOLID, entry.Player.IgnorePlayers, out rcr))
         {
             goal = new Location(rcr.HitData.Location);
         }
         else
         {
             goal = eye + forw * 50;
         }
         entry.Player.TheServer.Schedule.StartASyncTask(() =>
         {
             Stopwatch sw = new Stopwatch();
             sw.Start();
             List<Location> locs = entry.Player.TheRegion.FindPath(entry.Player.GetPosition(), goal, 75, 1.5f, true);
             sw.Stop();
             entry.Player.TheRegion.TheWorld.Schedule.ScheduleSyncTask(() =>
             {
                 if (locs != null)
                 {
                     entry.Player.Network.SendPacket(new PathPacketOut(locs));
                 }
                 entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Took " + sw.ElapsedMilliseconds + "ms, passed: " + (locs != null));
             });
         });
     }
     else if (arg0 == "gameMode" && entry.InputArguments.Count > 1)
     {
         GameMode mode;
         if (Enum.TryParse(entry.InputArguments[1].ToUpperInvariant(), out mode))
         {
             entry.Player.Mode = mode;
         }
     }
     else if (arg0 == "teleport" && entry.InputArguments.Count > 1)
     {
         entry.Player.Teleport(Location.FromString(entry.InputArguments[1]));
     }
     else if (arg0 == "loadPos")
     {
         entry.Player.UpdateLoadPos = !entry.Player.UpdateLoadPos;
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Now: " + (entry.Player.UpdateLoadPos ? "true" : "false"));
     }
     else if (arg0 == "tickRate")
     {
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Intended tick rate: " + entry.Player.TheServer.CVars.g_fps.ValueI + ", actual tick rate (last second): " + entry.Player.TheServer.TPS);
     }
     else if (arg0 == "paintBrush" && entry.InputArguments.Count > 1)
     {
         ItemStack its = entry.Player.TheServer.Items.GetItem("tools/paintbrush");
         byte col = Colors.ForName(entry.InputArguments[1]);
         its.Datum = col;
         its.DrawColor = Colors.ForByte(col);
         entry.Player.Items.GiveItem(its);
     }
     else if (arg0 == "paintBomb" && entry.InputArguments.Count > 1)
     {
         ItemStack its = entry.Player.TheServer.Items.GetItem("weapons/grenades/paintbomb", 10);
         byte col = Colors.ForName(entry.InputArguments[1]);
         its.Datum = col;
         its.DrawColor = Colors.ForByte(col);
         entry.Player.Items.GiveItem(its);
     }
     else if (arg0 == "sledgeHammer" && entry.InputArguments.Count > 1)
     {
         ItemStack its = entry.Player.TheServer.Items.GetItem("tools/sledgehammer");
         int bsd = BlockShapeRegistry.GetBSDFor(entry.InputArguments[1]);
         its.Datum = bsd;
         entry.Player.Items.GiveItem(its);
     }
     else if (arg0 == "blockDamage" && entry.InputArguments.Count > 1)
     {
         BlockDamage damage;
         if (Enum.TryParse(entry.InputArguments[1], out damage))
         {
             Location posBlock = (entry.Player.GetPosition() + new Location(0, 0, -0.05f)).GetBlockLocation();
             BlockInternal bi = entry.Player.TheRegion.GetBlockInternal(posBlock);
             bi.Damage = damage;
             entry.Player.TheRegion.SetBlockMaterial(posBlock, bi);
         }
         else
         {
             entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "/devel <subcommand> [ values ... ]");
         }
     }
     else if (arg0 == "blockShare" && entry.InputArguments.Count > 1)
     {
         Location posBlock = (entry.Player.GetPosition() + new Location(0, 0, -0.05f)).GetBlockLocation();
         BlockInternal bi = entry.Player.TheRegion.GetBlockInternal(posBlock);
         bool temp = entry.InputArguments[1].ToLowerFast() == "true";
         bi.BlockShareTex = temp;
         entry.Player.TheRegion.SetBlockMaterial(posBlock, bi);
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Block " + posBlock + " which is a " + bi.Material + " set ShareTex mode to " + temp + " yields " + bi.BlockShareTex);
     }
     else if (arg0 == "webPass" && entry.InputArguments.Count > 1)
     {
         entry.Player.PlayerConfig.Set("web.passcode", Utilities.HashQuick(entry.Player.Name.ToLowerFast(), entry.InputArguments[1]));
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "Set.");
     }
     else if (arg0 == "chunkTimes")
     {
         foreach (Tuple<string, double> time in entry.Player.TheRegion.Generator.GetTimings())
         {
             entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "--> " + time.Item1 + ": " + time.Item2);
         }
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "--> [Image]: " + entry.Player.TheRegion.TheServer.BlockImages.Timings_General);
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "--> [Image/A]: " + entry.Player.TheRegion.TheServer.BlockImages.Timings_A);
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "--> [Image/B]: " + entry.Player.TheRegion.TheServer.BlockImages.Timings_B);
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "--> [Image/C]: " + entry.Player.TheRegion.TheServer.BlockImages.Timings_C);
         entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "--> [Image/D]: " + entry.Player.TheRegion.TheServer.BlockImages.Timings_D);
         if (entry.InputArguments.Count > 1 && entry.InputArguments[1] == "clear")
         {
             entry.Player.TheRegion.Generator.ClearTimings();
             entry.Player.TheRegion.TheServer.BlockImages.Timings_General = 0;
             entry.Player.TheRegion.TheServer.BlockImages.Timings_A = 0;
             entry.Player.TheRegion.TheServer.BlockImages.Timings_B = 0;
             entry.Player.TheRegion.TheServer.BlockImages.Timings_C = 0;
             entry.Player.TheRegion.TheServer.BlockImages.Timings_D = 0;
         }
     }
     else
     {
         ShowUsage(entry);
         return;
     }
 }
示例#13
0
 public override Entity Create(Region tregion, BsonDocument doc)
 {
     ModelEntity ent = new ModelEntity(doc["mod_name"].AsString, tregion);
     ent.mode = (ModelCollisionMode)Enum.Parse(typeof(ModelCollisionMode), doc["mod_mode"].AsString);
     ent.CanLOD = doc["mod_lod"].AsBoolean;
     ent.ApplyPhysicsData(doc);
     return ent;
 }