Ejemplo n.º 1
0
 public ProduceUnit(ProduceUnit unit)
 {
     canProduce    = unit.canProduce;
     cost          = unit.cost;
     customTexture = unit.customTexture;
     customName    = unit.customName;
     dur           = unit.dur;
     rate          = unit.rate;
     amount        = unit.amount;
     curDur        = 0;
     groupIndex    = unit.groupIndex;
     lastTime      = 0;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Insert building's action queue to build something
        /// </summary>
        public void TellSelectedBuildingToBuild()
        {
            List <ModelComponent> selectedEntities = getGameModel().GetSelectionState().SelectedEntities;

            if (selectedEntities.Count > 0 && selectedEntities[0] is Building)
            {
                Building    b             = (Building)selectedEntities[0];
                ProduceUnit produceAction = null;
                if (b.Type.Equals("house"))
                {
                    produceAction = new ZRTSModel.ProduceUnit(b, "worker");
                }
                else
                {
                    produceAction = new ZRTSModel.ProduceUnit(b, "soldier");
                }

                b.BuildingActionQueue.AddChild(produceAction);
            }
        }
Ejemplo n.º 3
0
        protected override void Apply(AttributeLoader loader, object wrapperObj)
        {
            if (!(wrapperObj is AbilityAttributesWrapper w))
            {
                throw new System.InvalidCastException();
            }

            if (Resource1Cost != null || Resource2Cost != null || Resource1CostMult != null || Resource2CostMult != null)
            {
                var w2 = new CostAttributesWrapper(w.Cost);

                loader.ApplyPPatch(Resource1Cost, () => w2.Resource1Cost);
                loader.ApplyPMultPatch(Resource1CostMult, () => w2.Resource1Cost);

                loader.ApplyPPatch(Resource2Cost, () => w2.Resource2Cost);
                loader.ApplyPMultPatch(Resource2CostMult, () => w2.Resource2Cost);

                w.Cost = w2;
            }

            loader.ApplyPPatch(EdgeOfTargetShapeMinDistance, () => w.EdgeOfTargetShapeMinDistance, Fixed64.UnsafeFromDouble);
            loader.ApplyPMultPatch(EdgeOfTargetShapeMinDistanceMult, () => w.EdgeOfTargetShapeMinDistance);

            loader.ApplyPPatch(CooldownTimeSecs, () => w.CooldownTimeSecs, Fixed64.UnsafeFromDouble);
            loader.ApplyPMultPatch(CooldownTimeSecsMult, () => w.CooldownTimeSecs);

            loader.ApplyPPatch(WarmupTimeSecs, () => w.WarmupTimeSecs, Fixed64.UnsafeFromDouble);
            loader.ApplyPMultPatch(WarmupTimeSecsMult, () => w.WarmupTimeSecs);

            loader.ApplyPPatch(SharedCooldownChannel, () => w.SharedCooldownChannel);
            loader.ApplyPMultPatch(SharedCooldownChannelMult, () => w.SharedCooldownChannel);

            loader.ApplyPPatch(AbilityType, () => w.AbilityType);
            loader.ApplyPPatch(TargetingType, () => w.TargetingType);
            loader.ApplyPPatch(TargetAlignment, () => w.TargetAlignment);
            loader.ApplyPPatch(AbilityMapTargetLayers, () => w.AbilityMapTargetLayers);
            loader.ApplyPPatch(GroundAutoTargetAlignment, () => w.GroundAutoTargetAlignment);
            loader.ApplyPPatch(CasterMovesToTarget, () => w.CasterMovesToTarget);
            loader.ApplyPPatch(GroupActivationType, () => w.GroupActivationType);
            loader.ApplyPPatch(StartsRemovedInGameMode, () => w.StartsRemovedInGameMode);
            loader.ApplyPPatch(SkipCastOnArrivalConditions, () => w.SkipCastOnArrivalConditions);
            loader.ApplyPPatch(IsToggleable, () => w.IsToggleable);
            loader.ApplyPPatch(CastOnDeath, () => w.CastOnDeath);

            if (TargetHighlighting != null)
            {
                using (loader.logger.BeginScope($"TargetHighlighting:"))
                {
                    var w2 = new TargetHighlightingAttributesWrapper(w.TargetHighlighting);
                    TargetHighlighting.Apply(loader, w2, null);
                    w.TargetHighlighting = w2;
                }
            }
            if (Charges != null)
            {
                using (loader.logger.BeginScope($"Charges:"))
                {
                    var w2 = new ChargeAttributesWrapper(w.Charges);
                    Charges.Apply(loader, w2, null);
                    w.Charges = w2;
                }
            }
            if (Autocast != null)
            {
                using (loader.logger.BeginScope($"Autocast:"))
                {
                    var w2 = new AutocastAttributesWrapper(w.Autocast);
                    Autocast.Apply(loader, w2, null);
                    w.Autocast = w2;
                }
            }
            if (ProduceUnit != null)
            {
                using (loader.logger.BeginScope($"ProduceUnit:"))
                {
                    var w2 = new ProduceUnitAttributesWrapper(w.ProduceUnit);
                    ProduceUnit.Apply(loader, w2, null);
                    w.ProduceUnit = w2;
                }
            }
            if (UseWeapon != null)
            {
                using (loader.logger.BeginScope($"UseWeapon:"))
                {
                    var w2 = new UseWeaponAttributesWrapper(w.UseWeapon);
                    UseWeapon.Apply(loader, w2, null);
                    w.UseWeapon = w2;
                }
            }
            if (ChangeContext != null)
            {
                var w2 = new ChangeContextAttributesWrapper(w.ChangeContext);
                loader.ApplyPPatch(ChangeContext, () => w2.TargetContext);
                w.ChangeContext = w2;
            }
            if (AirSortie != null)
            {
                using (loader.logger.BeginScope($"AirSortie:"))
                {
                    var w2 = new AirSortieAttributesWrapper(w.AirSortie);
                    AirSortie.Apply(loader, w2, null);
                    w.AirSortie = w2;
                }
            }
            if (Salvage != null)
            {
                using (loader.logger.BeginScope($"Salvage:"))
                {
                    var w2 = new SalvageAttributesWrapper(w.Salvage);
                    Salvage.Apply(loader, w2, null);
                    w.Salvage = w2;
                }
            }
            if (ApplyStatusEffect.Count > 0)
            {
                using (loader.logger.BeginScope($"ApplyStatusEffect:"))
                {
                    var w2 = new ApplyStatusEffectAttributesWrapper(w.ApplyStatusEffect);

                    var statusEffectWrappers = w2.StatusEffectsToApply?.Select(x => new StatusEffectAttributesWrapper(x)).ToList() ?? new List <StatusEffectAttributesWrapper>();
                    loader.ApplyNamedLPatch(ApplyStatusEffect, statusEffectWrappers, (x) => new StatusEffectAttributesWrapper(x), nameof(StatusEffectAttributes));
                    w2.StatusEffectsToApply = statusEffectWrappers.ToArray();

                    w.ApplyStatusEffect = w2;
                }
            }
            if (Repair != null)
            {
                var w2 = new RepairAttributesWrapper(w.Repair);
                loader.ApplyPPatch(Repair, () => w2.WeaponID);
                w.Repair = w2;
            }
            if (SelfDestruct != null)
            {
                using (loader.logger.BeginScope($"SelfDestruct:"))
                {
                    var w2 = new SelfDestructAttributesWrapper(w.SelfDestruct);
                    SelfDestruct.Apply(loader, w2, null);
                    w.SelfDestruct = w2;
                }
            }
            if (ModifyInventory != null)
            {
                using (loader.logger.BeginScope($"ModifyInventory:"))
                {
                    var w2 = new ModifyInventoryAttributesWrapper(w.ModifyInventory);
                    ModifyInventory.Apply(loader, w2, null);
                    w.ModifyInventory = w2;
                }
            }
            if (RequiredResearch != null)
            {
                var w2 = new ResearchDependenciesAttributesWrapper(w.ResearchDependencies);
                loader.ApplyArrayPropertyPatch(RequiredResearch, w2, "RequiredResearch");
                w.ResearchDependencies = w2;
            }
            if (ActivationDependencies != null)
            {
                using (loader.logger.BeginScope($"ActivationDependencies:"))
                {
                    var w2 = new ActivationDependenciesAttributesWrapper(w.ActivationDependencies);
                    ActivationDependencies.Apply(loader, w2, null);
                    w.ActivationDependencies = w2;
                }
            }
            if (AutoToggleOffConditions != null)
            {
                using (loader.logger.BeginScope($"AutoToggleOffConditions:"))
                {
                    var w2 = new AutoToggleOffConditionsAttributesWrapper(w.AutoToggleOffConditions);
                    AutoToggleOffConditions.Apply(loader, w2, null);
                    w.AutoToggleOffConditions = w2;
                }
            }
            if (ChainCasting != null)
            {
                using (loader.logger.BeginScope($"ChainCasting:"))
                {
                    var w2 = new ChainCastingAttributesWrapper(w.ChainCasting);
                    ChainCasting.Apply(loader, w2, null);
                    w.ChainCasting = w2;
                }
            }
        }
 // Group Buildings Unit (Production)
 void ModifyGBU(int nl, int ol, int curLoc)
 {
     BuildingController buildCont = nTarget.buildingList[unitId].obj.GetComponent<BuildingController>();
     ProduceUnit[] copyArr = new ProduceUnit[ol];
     for(int x = 0; x < copyArr.Length; x++){
         copyArr[x] = buildCont.unitProduction.units[x];
     }
     buildCont.unitProduction.units = new ProduceUnit[nl];
     int y = 0;
     if(nl < ol){
         for(int x = 0; x < copyArr.Length; x++){
             if(x != curLoc){
                 buildCont.unitProduction.units[y] = copyArr[x];
                 y++;
             }
         }
     }
     else{
         for(int x = 0; x < buildCont.unitProduction.units.Length; x++){
             if(x != curLoc+1){
                 buildCont.unitProduction.units[x] = copyArr[y];
                 y++;
             }
         }
     }
 }
Ejemplo n.º 5
0
 public ProduceUnit(ProduceUnit unit)
 {
     canProduce = unit.canProduce;
     cost = unit.cost;
     customTexture = unit.customTexture;
     customName = unit.customName;
     dur = unit.dur;
     rate = unit.rate;
     amount = unit.amount;
     curDur = 0;
     groupIndex = unit.groupIndex;
     lastTime = 0;
 }