Esempio n. 1
0
        public BunkerCargo(ActorInitializer init, BunkerCargoInfo info)
        {
            self             = init.Self;
            Info             = info;
            Unloading        = false;
            checkTerrainType = info.UnloadTerrainTypes.Count > 0;
            wsb         = self.TraitOrDefault <WithSpriteBody>();
            bunkerState = BunkerState.NonBunkered;

            if (init.Contains <RuntimeCargoInit>())
            {
                cargo       = new Stack <Actor>(init.Get <RuntimeCargoInit, Actor[]>());
                totalWeight = cargo.Sum(c => GetWeight(c));
            }
            else if (init.Contains <CargoInit>())
            {
                foreach (var u in init.Get <CargoInit, string[]>())
                {
                    var unit = self.World.CreateActor(false, u.ToLowerInvariant(),
                                                      new TypeDictionary {
                        new OwnerInit(self.Owner)
                    });

                    cargo.Push(unit);
                }

                totalWeight = cargo.Sum(c => GetWeight(c));
            }
            else
            {
                foreach (var u in info.InitialUnits)
                {
                    var unit = self.World.CreateActor(false, u.ToLowerInvariant(),
                                                      new TypeDictionary {
                        new OwnerInit(self.Owner)
                    });

                    cargo.Push(unit);
                }

                totalWeight = cargo.Sum(c => GetWeight(c));
            }

            facing = Exts.Lazy(self.TraitOrDefault <IFacing>);
        }
Esempio n. 2
0
        public void ChangeState(BunkerState bunkered)
        {
            if (buildComplete)
            {
                switch (bunkered)
                {
                case BunkerState.NonBunkered:
                    if (!string.IsNullOrEmpty(Info.BunkerNotSequence))
                    {
                        wsb.PlayCustomAnimationRepeating(self, Info.BunkerNotSequence);
                    }
                    break;

                case BunkerState.Bunkered:
                    if (!string.IsNullOrEmpty(Info.BunkeredSequence))
                    {
                        wsb.PlayCustomAnimationRepeating(self, Info.BunkeredSequence);
                    }
                    break;
                }
            }
            bunkerState = bunkered;
        }