Esempio n. 1
0
        public override void onDecorateChunk(Chunk _Chunk)
        {
            base.onDecorateChunk(_Chunk);
            int var_Count = this.getCount();

            for (int i = 0; i < var_Count; i++)
            {
                EnvironmentObject var_EnvironmentObject = EnvironmentFactory.environmentFactory.createEnvironmentObject(this.RegionEnum, this.environmentEnum);

                int var_X = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.X * (Block.Block.BlockSize) - 1);
                int var_Y = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.Y * (Block.Block.BlockSize) - 1);

                var_EnvironmentObject.Position     = new Vector3(var_X + _Chunk.Position.X, var_Y + _Chunk.Position.Y, 0);
                var_EnvironmentObject.NextPosition = var_EnvironmentObject.Position;

                Block.Block var_Block = _Chunk.getBlockAtCoordinate(var_EnvironmentObject.Position);

                if (var_Block != null)
                {
                    if (var_Block.IsWalkAble && var_Block.Layer[1] == BlockEnum.Nothing)
                    {
                        if (this.isPreEnvironment)
                        {
                            var_Block.addPreEnvironmentObject(var_EnvironmentObject);
                        }
                        else
                        {
                            if (_Chunk.Parent != null)
                            {
                                //((Region.Region)_Chunk.Parent).getParent().addObject(var_EnvironmentObject, true, (Region.Region)_Chunk.Parent);
                            }
                            var_Block.addObject(var_EnvironmentObject);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public Object.Object addPreEnvironmentObject(Object.Object _Object, Region.Region _Region)
 {
     if (_Region != null)
     {
         Chunk.Chunk chunk = _Region.getChunkAtPosition(_Object.Position);
         if (chunk != null)
         {
             Block.Block var_Block = chunk.getBlockAtCoordinate(_Object.Position);
             if (var_Block != null)
             {
                 var_Block.addPreEnvironmentObject(_Object);
                 if (Configuration.Configuration.isHost)
                 {
                     Configuration.Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.UpdatePreEnvironmentObjectMessage(_Object), GameMessageImportance.VeryImportant);
                 }
             }
         }
     }
     else
     {
         Logger.Logger.LogInfo("World.addObject: Object konnte der Region nicht hinzugefügt werden, da diese null war");
     }
     return(_Object);
 }