Exemplo n.º 1
0
 void IResolveOrder.ResolveOrder(Actor self, NetWork.Order order)
 {
     if (devMode.Enabled && order.OrderString == "PowerOutage")
     {
         TriggerPowerOutage((int)order.ExtraData);
     }
 }
Exemplo n.º 2
0
        void IResolveOrder.ResolveOrder(Actor self, NetWork.Order order)
        {
            var os = order.OrderString;

            if (os != "PlaceBuilding" &&
                os != "LineBuild" &&
                os != "PlacePlug")
            {
                return;
            }

            self.World.AddFrameEndTask(w => {
                var prevItems = GetNumBuildables(self.Owner);


                var targetActor = w.GetActorById(order.ExtraData);

                if (targetActor == null || targetActor.IsDead)
                {
                    return;
                }

                var unit  = self.World.Map.Rules.Actors[order.TargetString];
                var queue = targetActor.TraitsImplementing <ProductionQueue>()
                            .FirstOrDefault(q => q.CanBuild(unit) && q.CurrentItem() != null && q.CurrentItem().Item == order.TargetString && q.CurrentItem().RemainingTime == 0);

                if (queue == null)
                {
                    return;
                }

                var producer = queue.MostLikelyProducer();
                var faction  = producer.Trait != null ? producer.Trait.Faction : self.Owner.Faction.InternalName;

                var buildingInfo  = unit.TraitInfo <BuildingInfo>();
                var buildableInfo = unit.TraitInfoOrDefault <BuildableInfo>();

                if (buildableInfo != null && buildableInfo.ForceFaction != null)
                {
                    faction = buildableInfo.ForceFaction;
                }

                if (os == "LineBuild")
                {
                }
                else if (os == "PlacePlug")
                {
                }
                else
                {
                    if (!self.World.CanPlaceBuilding(order.TargetString, buildingInfo, order.TargetLocation, null) ||
                        !buildingInfo.IsCloseEnoughToBase(self.World, order.Player, order.TargetString, order.TargetLocation))
                    {
                        return;
                    }


                    var building = w.CreateActor(order.TargetString, new TypeDictionary()
                    {
                        new LocationInit(order.TargetLocation),
                        new OwnerInit(order.Player),
                        new FactionInit(faction),
                    });

                    foreach (var s in buildingInfo.BuildSounds)
                    {
                        WarGame.Sound.PlayToPlayer(SoundType.World, order.Player, s, building.CenterPosition);
                    }
                }

                if (producer.Actor != null)
                {
                    foreach (var nbp in producer.Actor.TraitsImplementing <INotifyBuildingPlaced>())
                    {
                        nbp.BuildingPlaced(producer.Actor);
                    }
                }


                queue.FinishProduction();

                if (buildingInfo.RequiresBaseProvider)
                {
                    // May be null if the build anywhere cheat is active
                    // BuildingInfo.IsCloseEnoughToBase has already verified that this is a valid build location
                    var provider = buildingInfo.FindBaseProvider(w, self.Owner, order.TargetLocation);
                    if (provider != null)
                    {
                        provider.Trait <BaseProvider>().BeginCooldown();
                    }
                }

                if (GetNumBuildables(self.Owner) > prevItems)
                {
                    triggerNotification = true;
                }
            });
        }
Exemplo n.º 3
0
        void IResolveOrder.ResolveOrder(Actor self, NetWork.Order order)
        {

        }