示例#1
0
        internal World(Manifest manifest, Map map, OrderManager orderManager, bool isShellmap)
        {
            IsShellmap        = isShellmap;
            this.orderManager = orderManager;
            orderGenerator_   = new UnitOrderGenerator();
            Map = map;

            TileSet      = Rules.TileSets[Map.Tileset];
            SharedRandom = new XRandom(orderManager.LobbyInfo.GlobalSettings.RandomSeed);

            WorldActor = CreateActor("World", new TypeDictionary());
            ActorMap   = WorldActor.Trait <ActorMap>();
            ScreenMap  = WorldActor.Trait <ScreenMap>();

            // Add players
            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this);
            }

            // Set defaults for any unset stances
            foreach (var p in Players)
            {
                foreach (var q in Players)
                {
                    if (!p.Stances.ContainsKey(q))
                    {
                        p.Stances[q] = Stance.Neutral;
                    }
                }
            }

            Sound.SoundVolumeModifier = 1.0f;
        }
示例#2
0
        internal World(ModData modData, Map map, OrderManager orderManager, WorldType type)
        {
            Type           = type;
            OrderManager   = orderManager;
            orderGenerator = new UnitOrderGenerator();
            Map            = map;
            Timestep       = orderManager.LobbyInfo.GlobalSettings.Timestep;
            SharedRandom   = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
            LocalRandom    = new MersenneTwister();

            ModelCache = modData.ModelSequenceLoader.CacheModels(map, modData, map.Rules.ModelSequences);

            var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World";

            WorldActor = CreateActor(worldActorType, new TypeDictionary());
            ActorMap   = WorldActor.Trait <IActorMap>();
            ScreenMap  = WorldActor.Trait <ScreenMap>();
            Selection  = WorldActor.Trait <ISelection>();

            // Reset mask
            LongBitSet <PlayerBitMask> .Reset();

            // Add players
            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this);
            }

            // Set defaults for any unset stances
            foreach (var p in Players)
            {
                if (!p.Spectating)
                {
                    AllPlayersMask = AllPlayersMask.Union(p.PlayerMask);
                }

                foreach (var q in Players)
                {
                    SetUpPlayerMask(p, q);

                    if (!p.Stances.ContainsKey(q))
                    {
                        p.Stances[q] = Stance.Neutral;
                    }
                }
            }

            Game.Sound.SoundVolumeModifier = 1.0f;

            gameInfo = new GameInformation
            {
                Mod     = Game.ModData.Manifest.Id,
                Version = Game.ModData.Manifest.Metadata.Version,

                MapUid   = Map.Uid,
                MapTitle = Map.Title
            };

            RulesContainTemporaryBlocker = map.Rules.Actors.Any(a => a.Value.HasTraitInfo <ITemporaryBlockerInfo>());
        }
示例#3
0
        internal World(ModData modData, Map map, OrderManager orderManager, WorldT type)
        {
            Type           = type;
            OrderManager   = orderManager;
            orderGenerator = new UnitOrderGenerator();
            Map            = map;
            Timestep       = orderManager.LobbyInfo.GlobalSettings.Timestep;
            SharedRandom   = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);

            ModelCache = modData.ModelSequenceLoader.CachModels(map, modData, map.Rules.ModelSequences);

            var worldActorT = type == WorldT.Editor ? "EditorWorld" : "World";

            WorldActor = CreateActor(worldActorT, new TypeDictionary());
            ActorMap   = WorldActor.Trait <IActorMap>();
            ScreenMap  = WorldActor.Trait <ScreenMap>();

            //Add players
            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this);
            }

            //Set defaults for any unset stances
            foreach (var p in Players)
            {
                foreach (var q in Players)
                {
                    if (!p.Stances.ContainsKey(q))
                    {
                        p.Stances[q] = Stance.Neutral;
                    }
                }
            }
        }
示例#4
0
        internal World(Map map, OrderManager orderManager, WorldType type)
        {
            Type           = type;
            OrderManager   = orderManager;
            orderGenerator = new UnitOrderGenerator();
            Map            = map;
            Timestep       = orderManager.LobbyInfo.GlobalSettings.Timestep;

            TileSet      = map.Rules.TileSets[Map.Tileset];
            SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);

            var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World";

            WorldActor = CreateActor(worldActorType, new TypeDictionary());
            ActorMap   = WorldActor.Trait <ActorMap>();
            ScreenMap  = WorldActor.Trait <ScreenMap>();

            // Add players
            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this);
            }

            // Set defaults for any unset stances
            foreach (var p in Players)
            {
                foreach (var q in Players)
                {
                    if (!p.Stances.ContainsKey(q))
                    {
                        p.Stances[q] = Stance.Neutral;
                    }
                }
            }

            Game.Sound.SoundVolumeModifier = 1.0f;

            gameInfo = new GameInformation
            {
                Mod     = Game.ModData.Manifest.Mod.Id,
                Version = Game.ModData.Manifest.Mod.Version,

                MapUid   = Map.Uid,
                MapTitle = Map.Title
            };

            if (!LobbyInfo.GlobalSettings.Shroud)
            {
                foreach (var player in Players)
                {
                    player.Shroud.ExploreAll(this);
                }
            }
        }
示例#5
0
 public bool ToggleInputMode <T>() where T : IOrderGenerator, new()
 {
     if (OrderGenerator is T)
     {
         CancelInputMode();
         return(false);
     }
     else
     {
         OrderGenerator = new T();
         return(true);
     }
 }
        public void StartConstructUnit(ObjectDefinition unitDefinition)
        {
            // TODO: Handle ONLY_BY_AI
            // TODO: Copy default settings from DefaultThingTemplate

            // TODO: Check that the building can build that unit.
            // TODO: Check that the unit has been unlocked.
            // TODO: Check that the building isn't building something else right now?

            var gameData        = Game.AssetStore.GameData.Current;
            var definitionIndex = unitDefinition.InternalId;

            ActiveGenerator = new TrainUnitOrderGenerator(unitDefinition, definitionIndex, gameData);
        }
示例#7
0
        public void StartConstructUnit(ObjectDefinition unitDefinition)
        {
            // TODO: Handle ONLY_BY_AI
            // TODO: Copy default settings from DefaultThingTemplate

            // TODO: Check that the building can build that unit.
            // TODO: Check that the unit has been unlocked.
            // TODO: Check that the building isn't building something else right now?

            var gameData        = Game.ContentManager.IniDataContext.GameData;
            var definitionIndex = Game.ContentManager.IniDataContext.Objects.IndexOf(unitDefinition) + 1;

            ActiveGenerator = new TrainUnitOrderGenerator(unitDefinition, definitionIndex, gameData);
        }
示例#8
0
        public CustomerOrderCreator(Quantity defaultCustomerOrderQuantityPerCycle)
        {
            if (defaultCustomerOrderQuantityPerCycle != null &&
                defaultCustomerOrderQuantityPerCycle.IsSmallerThan(
                    _defaultCustomerOrderQuantityPerCycle))
            {
                _defaultCustomerOrderQuantityPerCycle = defaultCustomerOrderQuantityPerCycle;
            }

            var orderArrivalRate = new OrderArrivalRate(0.025);
            IDbMasterDataCache masterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache();

            _orderGenerator = TestScenario.GetOrderGenerator(new MinDeliveryTime(200),
                                                             new MaxDeliveryTime(1430), orderArrivalRate, masterDataCache.M_ArticleGetAll(),
                                                             masterDataCache.M_BusinessPartnerGetAll());
        }
示例#9
0
        internal World(ModData modData, Map map, OrderManager orderManager, WorldType type)
        {
            Type           = type;
            OrderManager   = orderManager;
            orderGenerator = new UnitOrderGenerator();
            Map            = map;
            Timestep       = orderManager.LobbyInfo.GlobalSettings.Timestep;
            SharedRandom   = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
            LocalRandom    = new MersenneTwister();

            ModelCache = modData.ModelSequenceLoader.CacheModels(map, modData, map.Rules.ModelSequences);

            var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World";

            WorldActor      = CreateActor(worldActorType, new TypeDictionary());
            ActorMap        = WorldActor.Trait <IActorMap>();
            ScreenMap       = WorldActor.Trait <ScreenMap>();
            Selection       = WorldActor.Trait <ISelection>();
            OrderValidators = WorldActor.TraitsImplementing <IValidateOrder>().ToArray();

            LongBitSet <PlayerBitMask> .Reset();

            // Create an isolated RNG to simplify synchronization between client and server player faction/spawn assignments
            var playerRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);

            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this, playerRandom);
            }

            Game.Sound.SoundVolumeModifier = 1.0f;

            gameInfo = new GameInformation
            {
                Mod     = Game.ModData.Manifest.Id,
                Version = Game.ModData.Manifest.Metadata.Version,

                MapUid   = Map.Uid,
                MapTitle = Map.Title
            };

            RulesContainTemporaryBlocker = map.Rules.Actors.Any(a => a.Value.HasTraitInfo <ITemporaryBlockerInfo>());
            gameSettings = Game.Settings.Game;
        }
        public void StartConstructBuilding(ObjectDefinition buildingDefinition)
        {
            if (!buildingDefinition.KindOf.Get(ObjectKinds.Structure))
            {
                throw new ArgumentException("Building must have the STRUCTURE kind.", nameof(buildingDefinition));
            }

            // TODO: Handle ONLY_BY_AI
            // TODO: Copy default settings from DefaultThingTemplate

            /*if (buildingDefinition.Buildable != ObjectBuildableType.Yes)
             * {
             *  throw new ArgumentException("Building must be buildable.", nameof(buildingDefinition));
             * }*/

            // TODO: Check that the builder can build that building.
            // TODO: Check that the building has been unlocked.
            // TODO: Check that the builder isn't building something else right now?

            var gameData        = Game.AssetStore.GameData.Current;
            var definitionIndex = buildingDefinition.InternalId;

            ActiveGenerator = new ConstructBuildingOrderGenerator(buildingDefinition, definitionIndex, gameData);
        }
        public void OnActivate()
        {
            if (!_worldPosition.HasValue || ActiveGenerator == null)
            {
                return;
            }

            var result = ActiveGenerator.TryActivate(Game.Scene3D);

            switch (result)
            {
            case OrderGeneratorResult.Success success:
            {
                // TODO: Wrong place, wrong behavior.
                Game.Audio.PlayAudioEvent("DozerUSAVoiceBuild");

                foreach (var order in success.Orders)
                {
                    Game.NetworkMessageBuffer.AddLocalOrder(order);
                }

                if (success.Exit)
                {
                    ActiveGenerator = null;
                }

                break;
            }

            case OrderGeneratorResult.FailureResult _:
                // TODO: Wrong place, wrong behavior.
                Game.Audio.PlayAudioEvent("DozerUSAVoiceBuildNot");
                // TODO: Show error message in HUD
                break;
            }
        }
示例#12
0
 public void CancelInputMode()
 {
     OrderGenerator = new UnitOrderGenerator();
 }
示例#13
0
 public AppService(IOrderGenerator orderGenerator,
                   IOrderBasket orderBasket)
 {
     this.orderGenerator = orderGenerator;
     this.orderBasket    = orderBasket;
 }
示例#14
0
 public void SetRallyPoint()
 {
     ActiveGenerator = new RallyPointOrderGenerator();
 }
 public static void Reset() => current = null;