Example #1
0
 public void BuildWorld()
 {
     if (TheSun != null)
     {
         TheSun.Destroy();
         MainWorldView.Lights.Remove(TheSun);
         ThePlanet.Destroy();
         MainWorldView.Lights.Remove(ThePlanet);
         TheSunClouds.Destroy();
         MainWorldView.Lights.Remove(TheSunClouds);
     }
     // TODO: DESTROY OLD REGION!
     // TODO: Radius -> max view rad * 2
     // TODO: Size -> max view rad * 2 + 30 * 2
     TheSun = new SkyLight(Location.Zero, Chunk.CHUNK_SIZE * 30, SunLightDef, new Location(0, 0, -1), Chunk.CHUNK_SIZE * 35, false);
     MainWorldView.Lights.Add(TheSun);
     // TODO: Separate cloud quality CVar?
     TheSunClouds = new SkyLight(Location.Zero, Chunk.CHUNK_SIZE * 30, CloudSunLightDef, new Location(0, 0, -1), Chunk.CHUNK_SIZE * 35, true);
     MainWorldView.Lights.Add(TheSunClouds);
     // TODO: Separate planet quality CVar?
     ThePlanet = new SkyLight(Location.Zero, Chunk.CHUNK_SIZE * 30, PlanetLightDef, new Location(0, 0, -1), Chunk.CHUNK_SIZE * 35, false);
     MainWorldView.Lights.Add(ThePlanet);
     TheRegion = new Region();
     TheRegion.TheClient = this;
     TheRegion.BuildWorld();
     Player = new PlayerEntity(TheRegion);
     TheRegion.SpawnEntity(Player);
     onCloudShadowChanged(null, null);
 }
Example #2
0
 public override Entity Create(Region tregion, byte[] data)
 {
     int col = Utilities.BytesToInt(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength, 4));
     GlowstickEntity ge = new GlowstickEntity(tregion, col);
     ge.ApplyPhysicsNetworkData(data);
     return ge;
 }
Example #3
0
 public PrimitiveModelEntity(string modelname, Region tregion)
     : base(tregion, false)
 {
     model = tregion.TheClient.Models.GetModel(modelname);
     Gravity = Location.Zero;
     Velocity = Location.Zero;
 }
Example #4
0
 public Entity(Region tregion, bool tickme, bool cast_shadows)
 {
     TheRegion = tregion;
     TheClient = tregion.TheClient;
     Ticks = tickme;
     WireColor = new OpenTK.Graphics.Color4((float)Utilities.UtilRandom.NextDouble(), (float)Utilities.UtilRandom.NextDouble(), 0f, 1f);
     CastShadows = cast_shadows;
 }
Example #5
0
 public override Entity Create(Region tregion, byte[] data)
 {
     int itsbyte = Utilities.BytesToInt(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength, 4));
     BlockInternal bi = BlockInternal.FromItemDatum(itsbyte);
     StaticBlockEntity sbe = new StaticBlockEntity(tregion, bi.Material, bi.BlockPaint);
     sbe.ApplyPhysicsNetworkData(data);
     return sbe;
 }
Example #6
0
 public GrenadeEntity(Region tregion, bool shadows)
     : base(tregion, true, shadows)
 {
     model = TheClient.Models.Sphere;
     GColor = new Color4(0f, 0f, 0f, 1f);
     Shape = new CylinderShape(0.2f, 0.05f);
     Bounciness = 0.95f;
     SetMass(1);
 }
Example #7
0
 public BlockItemEntity(Region tregion, Material tmat, byte dat, byte tpaint, BlockDamage tdamage)
     : base(tregion, false, true)
 {
     Mat = tmat;
     Dat = dat;
     Paint = tpaint;
     Damage = tdamage;
     Shape = BlockShapeRegistry.BSD[dat].GetShape(Damage, out Offset, !(this is StaticBlockEntity));
     SetMass(20);
 }
Example #8
0
 public override Entity Create(Region tregion, byte[] data)
 {
     int xwidth = (int)Utilities.BytesToInt(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength, 4));
     int ywidth = (int)Utilities.BytesToInt(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength + 4, 4));
     int zwidth = (int)Utilities.BytesToInt(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength + 4 + 4, 4));
     BlockInternal[] bi = new BlockInternal[xwidth * ywidth * zwidth];
     for (int i = 0; i < bi.Length; i++)
     {
         bi[i]._BlockMaterialInternal = Utilities.BytesToUshort(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength + (4 + 4 + 4) + i * 2, 2));
         bi[i].BlockData = data[PhysicsEntity.PhysicsNetworkDataLength + (4 + 4 + 4) + bi.Length * 2 + i];
         bi[i].BlockPaint = data[PhysicsEntity.PhysicsNetworkDataLength + (4 + 4 + 4) + bi.Length * 3 + i];
     }
     BGETraceMode tm = (BGETraceMode)data[PhysicsEntity.PhysicsNetworkDataLength + (4 + 4 + 4) + bi.Length * 4];
     BlockGroupEntity bge = new BlockGroupEntity(tregion, tm, bi, xwidth, ywidth, zwidth, Location.FromDoubleBytes(data, PhysicsEntity.PhysicsNetworkDataLength + (4 + 4 + 4) + bi.Length * 4 + 1 + 4));
     bge.Color = System.Drawing.Color.FromArgb(Utilities.BytesToInt(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength + (4 + 4 + 4) + bi.Length * 4 + 1, 4)));
     bge.scale = Location.FromDoubleBytes(data, PhysicsEntity.PhysicsNetworkDataLength + (4 + 4 + 4) + bi.Length * 4 + 1 + 4 + 24);
     bge.ApplyPhysicsNetworkData(data);
     return bge;
 }
Example #9
0
 public BlockGroupEntity(Region tregion, BGETraceMode mode, BlockInternal[] blocks, int xwidth, int ywidth, int zwidth, Location sOffs)
     : base(tregion, true, true)
 {
     SetMass(blocks.Length);
     XWidth = xwidth;
     YWidth = ywidth;
     ZWidth = zwidth;
     Blocks = blocks;
     TraceMode = mode;
     if (TraceMode == BGETraceMode.PERFECT)
     {
         Vector3 shoffs;
         Shape = new MobileChunkShape(new Vector3i(xwidth, ywidth, zwidth), blocks, out shoffs);
     }
     else
     {
         Shape = CalculateHullShape(out shapeOffs);
     }
     SysConsole.Output(OutputType.INFO, "Shape offs : " + shapeOffs + " vs " + sOffs);
     shapeOffs = sOffs;
 }
Example #10
0
 public LiquidVolume(Region tregion)
 {
     TheRegion = tregion;
 }
Example #11
0
 public GlowstickEntity(Region tregion, int color)
     : base(tregion, false)
 {
     System.Drawing.Color col = System.Drawing.Color.FromArgb(color);
     GColor = new Color4(col.R, col.G, col.B, col.A);
 }
 public override Entity Create(Region tregion, byte[] data)
 {
     DataStream ds = new DataStream(data);
     DataReader dr = new DataReader(ds);
     GenericCharacterEntity ent = new GenericCharacterEntity(tregion);
     ent.SetPosition(Location.FromDoubleBytes(dr.ReadBytes(24), 0));
     ent.SetOrientation(new BEPUutilities.Quaternion(dr.ReadFloat(), dr.ReadFloat(), dr.ReadFloat(), dr.ReadFloat()));
     ent.SetMass(dr.ReadFloat());
     ent.CBAirForce = dr.ReadFloat();
     ent.CBAirSpeed = dr.ReadFloat();
     ent.CBCrouchSpeed = dr.ReadFloat();
     ent.CBDownStepHeight = dr.ReadFloat();
     ent.CBGlueForce = dr.ReadFloat();
     ent.CBHHeight = dr.ReadFloat();
     ent.CBJumpSpeed = dr.ReadFloat();
     ent.CBMargin = dr.ReadFloat();
     ent.CBMaxSupportSlope = dr.ReadFloat();
     ent.CBMaxTractionSlope = dr.ReadFloat();
     ent.CBProneSpeed = dr.ReadFloat();
     ent.CBRadius = dr.ReadFloat();
     ent.CBSlideForce = dr.ReadFloat();
     ent.CBSlideJumpSpeed = dr.ReadFloat();
     ent.CBSlideSpeed = dr.ReadFloat();
     ent.CBStandSpeed = dr.ReadFloat();
     ent.CBStepHeight = dr.ReadFloat();
     ent.CBTractionForce = dr.ReadFloat();
     ent.PreRot *= Matrix4d.CreateRotationX(dr.ReadFloat() * Utilities.PI180);
     ent.PreRot *= Matrix4d.CreateRotationY(dr.ReadFloat() * Utilities.PI180);
     ent.PreRot *= Matrix4d.CreateRotationZ(dr.ReadFloat() * Utilities.PI180);
     ent.mod_scale = dr.ReadFloat();
     ent.PreRot = Matrix4d.Scale(ent.mod_scale) * ent.PreRot;
     ent.color = System.Drawing.Color.FromArgb(dr.ReadInt());
     byte dtx = dr.ReadByte();
     ent.Visible = (dtx & 1) == 1;
     int solidity = (dtx & (2 | 4 | 8));
     if (solidity == 2)
     {
         ent.CGroup = CollisionUtil.Solid;
     }
     else if (solidity == 4)
     {
         ent.CGroup = CollisionUtil.NonSolid;
     }
     else if (solidity == (2 | 4))
     {
         ent.CGroup = CollisionUtil.Item;
     }
     else if (solidity == 8)
     {
         ent.CGroup = CollisionUtil.Player;
     }
     else if (solidity == (2 | 8))
     {
         ent.CGroup = CollisionUtil.Water;
     }
     else if (solidity == (2 | 4 | 8))
     {
         ent.CGroup = CollisionUtil.WorldSolid;
     }
     else if (solidity == 16)
     {
         ent.CGroup = CollisionUtil.Character;
     }
     ent.model = tregion.TheClient.Models.GetModel(tregion.TheClient.Network.Strings.StringForIndex(dr.ReadInt()));
     dr.Close();
     return ent;
 }
Example #13
0
 public abstract Entity Create(Region tregion, byte[] e);
Example #14
0
 public override Entity Create(Region tregion, byte[] data)
 {
     GrenadeEntity ge = new GrenadeEntity(tregion, true);
     ge.ApplyPhysicsNetworkData(data);
     return ge;
 }
Example #15
0
 public PlayerEntity(Region tregion)
     : base(tregion)
 {
     SetMass(tmass);
     mod_scale = 1.5f;
     CanRotate = false;
     EID = -1;
     model = TheClient.Models.GetModel("players/human_male_004");
     model.LoadSkin(TheClient.Textures);
     CGroup = CollisionUtil.Player;
     NMTWOWorld.ForceUpdater.Gravity = TheRegion.PhysicsWorld.ForceUpdater.Gravity;
     NMTWOWorld.TimeStepSettings.MaximumTimeStepsPerFrame = 10;
     SetPosition(new Location(0, 0, 1000));
 }
Example #16
0
 public override Entity Create(Region tregion, byte[] e)
 {
     if (e.Length < 4 + 24 + 24)
     {
         return null;
     }
     BasicPrimitiveEntity bpe = new BasicPrimitiveEntity(tregion, false);
     bpe.Scale = new Location(Utilities.BytesToFloat(Utilities.BytesPartial(e, 0, 4)));
     bpe.SetPosition(Location.FromDoubleBytes(e, 4));
     bpe.SetVelocity(Location.FromDoubleBytes(e, 4 + 24));
     return bpe;
 }
Example #17
0
 public override Entity Create(Region tregion, byte[] data)
 {
     Material mat = (Material)Utilities.BytesToUshort(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength, 2));
     byte dat = data[PhysicsEntity.PhysicsNetworkDataLength + 2];
     byte tpa = data[PhysicsEntity.PhysicsNetworkDataLength + 3];
     byte damage = data[PhysicsEntity.PhysicsNetworkDataLength + 4];
     BlockItemEntity bie = new BlockItemEntity(tregion, mat, dat, tpa, (BlockDamage)damage);
     bie.ApplyPhysicsNetworkData(data);
     return bie;
 }
Example #18
0
 public CharacterEntity(Region tregion)
     : base(tregion, true, true)
 {
 }
 public GenericCharacterEntity(Region tregion)
     : base(tregion)
 {
 }
Example #20
0
 public FireEntity(Location spawn, Entity attached_to, Region tregion)
     : base(tregion, false)
 {
     AttachedTo = attached_to;
     SetPosition(spawn);
 }
Example #21
0
 public ModelEntity(string model_in, Region tregion)
     : base(tregion, true, true)
 {
     mod = model_in;
 }
Example #22
0
 public override Entity Create(Region tregion, byte[] data)
 {
     ModelEntity me = new ModelEntity(tregion.TheClient.Network.Strings.StringForIndex(Utilities.BytesToInt(Utilities.BytesPartial(data, PhysicsEntity.PhysicsNetworkDataLength, 4))), tregion);
     me.ApplyPhysicsNetworkData(data);
     byte moder = data[PhysicsEntity.PhysicsNetworkDataLength + 4];
     me.mode = (ModelCollisionMode)moder;
     me.scale = Location.FromDoubleBytes(data, PhysicsEntity.PhysicsNetworkDataLength + 4 + 1);
     return me;
 }
Example #23
0
 public StaticBlockEntity(Region tregion, Material mat, byte paint)
     : base(tregion, mat, 0, paint, BlockDamage.NONE)
 {
     SetMass(0);
 }
Example #24
0
 public PrimitiveEntity(Region tregion, bool cast_shadows)
     : base(tregion, true, cast_shadows)
 {
 }
Example #25
0
 public override Entity Create(Region tregion, byte[] e)
 {
     if (e.Length < 4 + 24 + 24 + 16 + 24 + 4)
     {
         return null;
     }
     BasicPrimitiveEntity bpe = new BasicPrimitiveEntity(tregion, false);
     bpe.Position = Location.FromDoubleBytes(e, 0);
     bpe.Velocity = Location.FromDoubleBytes(e, 24);
     bpe.Angles = Utilities.BytesToQuaternion(e, 24 + 24);
     bpe.Scale = Location.FromDoubleBytes(e, 24 + 24 + 16);
     bpe.Gravity = Location.FromDoubleBytes(e, 24 + 24 + 16 + 24);
     bpe.model = tregion.TheClient.Models.GetModel(tregion.TheClient.Network.Strings.StringForIndex(Utilities.BytesToInt(Utilities.BytesPartial(e, 24 + 24 + 16 + 24 + 24, 4))));
     return bpe;
 }
Example #26
0
 public PhysicsEntity(Region tregion, bool ticks, bool cast_shadows)
     : base(tregion, ticks, cast_shadows)
 {
     Gravity = new Location(TheRegion.PhysicsWorld.ForceUpdater.Gravity);
     CGroup = CollisionUtil.Solid;
 }
Example #27
0
 public Cloud(Region tregion, Location pos)
 {
     TheRegion = tregion;
     Position = pos;
 }