Exemplo n.º 1
0
        private IEnumerable <IEnumerable <Attribute> > GetAllAttributeSets(AttributeLevels level)
        {
            if (level.HasFlag(AttributeLevels.Declared))
            {
                yield return(DeclaredAttributesList);
            }

            if (level.HasFlag(AttributeLevels.ParentComponent))
            {
                yield return(ParentComponentAttributes);
            }

            if (level.HasFlag(AttributeLevels.Assembly))
            {
                yield return(AssemblyAttributesList);
            }

            if (level.HasFlag(AttributeLevels.Global))
            {
                yield return(GlobalAttributesList);
            }

            if (level.HasFlag(AttributeLevels.Component))
            {
                yield return(ComponentAttributesList);
            }
        }
Exemplo n.º 2
0
        private IEnumerable <Attribute> GetAllAttributes(AttributeLevels level)
        {
            IEnumerable <Attribute> result = Enumerable.Empty <Attribute>();

            if (level.HasFlag(AttributeLevels.Declared))
            {
                result = result.Concat(DeclaredAttributesList);
            }

            if (level.HasFlag(AttributeLevels.ParentComponent))
            {
                result = result.Concat(ParentComponentAttributes);
            }

            if (level.HasFlag(AttributeLevels.Assembly))
            {
                result = result.Concat(AssemblyAttributesList);
            }

            if (level.HasFlag(AttributeLevels.Global))
            {
                result = result.Concat(GlobalAttributesList);
            }

            if (level.HasFlag(AttributeLevels.Component))
            {
                result = result.Concat(ComponentAttributesList);
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Applied after OnPrefabInit runs.
        /// </summary>
        internal static void Postfix(AttributeLevels __instance)
        {
            var levels = __instance.levels;

            if (levels != null)
            {
                var fl = __instance.gameObject.AddOrGet <FastAttributeLevels>();
                fl.Initialize(levels);
            }
            else
            {
                PUtil.LogWarning("Tried to add fast levels, but no attributes found!");
            }
        }
Exemplo n.º 4
0
    private void CopyMinion(MinionIdentity src_id, StoredMinionIdentity dest_id)
    {
        dest_id.storedName      = src_id.name;
        dest_id.nameStringKey   = src_id.nameStringKey;
        dest_id.gender          = src_id.gender;
        dest_id.genderStringKey = src_id.genderStringKey;
        dest_id.arrivalTime     = src_id.arrivalTime;
        dest_id.voiceIdx        = src_id.voiceIdx;
        dest_id.bodyData        = src_id.bodyData;
        Traits component = src_id.GetComponent <Traits>();

        dest_id.traitIDs = new List <string>(component.GetTraitIds());
        dest_id.assignableProxy.Set(src_id.assignableProxy.Get());
        dest_id.assignableProxy.Get().SetTarget(dest_id, dest_id.gameObject);
        Accessorizer component2 = src_id.GetComponent <Accessorizer>();

        dest_id.accessories = component2.GetAccessories();
        ConsumableConsumer component3 = src_id.GetComponent <ConsumableConsumer>();

        if (component3.forbiddenTags != null)
        {
            dest_id.forbiddenTags = new List <Tag>(component3.forbiddenTags);
        }
        MinionResume component4 = src_id.GetComponent <MinionResume>();

        dest_id.MasteryBySkillID      = component4.MasteryBySkillID;
        dest_id.AptitudeBySkillGroup  = component4.AptitudeBySkillGroup;
        dest_id.TotalExperienceGained = component4.TotalExperienceGained;
        dest_id.currentHat            = component4.CurrentHat;
        dest_id.targetHat             = component4.TargetHat;
        ChoreConsumer component5 = src_id.GetComponent <ChoreConsumer>();

        dest_id.choreGroupPriorities = component5.GetChoreGroupPriorities();
        AttributeLevels component6 = src_id.GetComponent <AttributeLevels>();

        component6.OnSerializing();
        dest_id.attributeLevels = new List <AttributeLevels.LevelSaveLoad>(component6.SaveLoadLevels);
        StoreModifiers(src_id, dest_id);
        Schedulable component7 = src_id.GetComponent <Schedulable>();
        Schedule    schedule   = component7.GetSchedule();

        if (schedule != null)
        {
            schedule.Unassign(component7);
            Schedulable component8 = dest_id.GetComponent <Schedulable>();
            schedule.Assign(component8);
        }
    }
 public BipedTransitionLayer(Navigator navigator, float floor_speed, float ladder_speed)
     : base(navigator)
 {
     navigator.Subscribe(1773898642, delegate
     {
         isWalking = true;
     });
     navigator.Subscribe(1597112836, delegate
     {
         isWalking = false;
     });
     floorSpeed      = floor_speed;
     ladderSpeed     = ladder_speed;
     jetPackSpeed    = floor_speed;
     movementSpeed   = Db.Get().AttributeConverters.MovementSpeed.Lookup(navigator.gameObject);
     attributeLevels = navigator.GetComponent <AttributeLevels>();
 }
Exemplo n.º 6
0
    protected override bool OnWorkTick(Worker worker, float dt)
    {
        CircuitManager circuitManager = Game.Instance.circuitManager;
        bool           flag           = false;

        if (circuitManager != null)
        {
            ushort circuitID = circuitManager.GetCircuitID(powerCell);
            bool   flag2     = circuitManager.HasBatteries(circuitID);
            flag = ((flag2 && circuitManager.GetMinBatteryPercentFullOnCircuit(circuitID) < 1f) || (!flag2 && circuitManager.HasConsumers(circuitID)));
        }
        AttributeLevels component = worker.GetComponent <AttributeLevels>();

        if ((Object)component != (Object)null)
        {
            component.AddExperience(Db.Get().Attributes.Athletics.Id, dt, DUPLICANTSTATS.ATTRIBUTE_LEVELING.ALL_DAY_EXPERIENCE);
        }
        return(!flag);
    }
            public static void Postfix(ref Worker worker, float dt, ref ManualGenerator __instance)
            {
                if (!Settings.Instance.Gym.IncludeRoom)
                {
                    return;
                }
                if (RoomTypes_AllModded.IsInTheRoom(__instance, RoomTypeGymData.RoomId))
                {
                    if (string.IsNullOrEmpty(AthleticsId))
                    {
                        AthleticsId = Db.Get().Attributes.Athletics.Id;
                    }

                    AttributeLevels component = worker.GetComponent <AttributeLevels>();
                    if (component != null && Settings.Instance.Gym.Bonus.HasValue)
                    {
                        component.AddExperience(AthleticsId,
                                                dt * Settings.Instance.Gym.Bonus.Value,
                                                DUPLICANTSTATS.ATTRIBUTE_LEVELING.ALL_DAY_EXPERIENCE);
                    }
                }
            }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the sequence of attributes of the specified type.
        /// </summary>
        /// <typeparam name="TAttribute">The type of the attribute.</typeparam>
        /// <param name="levels">The attribute levels.</param>
        /// <param name="predicate">The predicate.</param>
        /// <returns>The sequence of attributes found.</returns>
        public IEnumerable <TAttribute> GetAll <TAttribute>(AttributeLevels levels, Func <TAttribute, bool> predicate = null)
        {
            var attributes = GetAllAttributes(levels);

            return(FilterAttributes(attributes, predicate));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the first attribute of the specified type or null if no such attribute is found.
        /// </summary>
        /// <typeparam name="TAttribute">The type of the attribute.</typeparam>
        /// <param name="levels">The attribute levels.</param>
        /// <param name="predicate">The predicate.</param>
        /// <returns>The first attribute found or null.</returns>
        public TAttribute Get <TAttribute>(AttributeLevels levels, Func <TAttribute, bool> predicate = null)
        {
            var attributes = GetAllAttributes(levels);

            return(GetFirstOrDefaultAttribute(attributes, predicate));
        }
Exemplo n.º 10
0
 public AttributeFilter <TAttribute> At(AttributeLevels levels)
 {
     Levels = levels;
     return(this);
 }
Exemplo n.º 11
0
    private static void CopyMinion(StoredMinionIdentity src_id, MinionIdentity dest_id)
    {
        dest_id.SetName(src_id.storedName);
        dest_id.nameStringKey   = src_id.nameStringKey;
        dest_id.gender          = src_id.gender;
        dest_id.genderStringKey = src_id.genderStringKey;
        dest_id.arrivalTime     = src_id.arrivalTime;
        dest_id.voiceIdx        = src_id.voiceIdx;
        dest_id.bodyData        = src_id.bodyData;
        if (src_id.traitIDs != null)
        {
            Traits component = dest_id.GetComponent <Traits>();
            component.SetTraitIds(src_id.traitIDs);
        }
        if (src_id.accessories != null)
        {
            Accessorizer component2 = dest_id.GetComponent <Accessorizer>();
            component2.SetAccessories(src_id.accessories);
        }
        ConsumableConsumer component3 = dest_id.GetComponent <ConsumableConsumer>();

        if (src_id.forbiddenTags != null)
        {
            component3.forbiddenTags = src_id.forbiddenTags.ToArray();
        }
        if (src_id.MasteryBySkillID != null)
        {
            MinionResume component4 = dest_id.GetComponent <MinionResume>();
            component4.RestoreResume(src_id.MasteryBySkillID, src_id.AptitudeBySkillGroup, src_id.TotalExperienceGained);
            component4.SetHats(src_id.currentHat, src_id.targetHat);
        }
        if (src_id.choreGroupPriorities != null)
        {
            ChoreConsumer component5 = dest_id.GetComponent <ChoreConsumer>();
            component5.SetChoreGroupPriorities(src_id.choreGroupPriorities);
        }
        AttributeLevels component6 = dest_id.GetComponent <AttributeLevels>();

        if (src_id.attributeLevels != null)
        {
            component6.SaveLoadLevels = src_id.attributeLevels.ToArray();
            component6.OnDeserialized();
        }
        dest_id.GetComponent <Accessorizer>().ApplyAccessories();
        dest_id.assignableProxy = new Ref <MinionAssignablesProxy>();
        dest_id.assignableProxy.Set(src_id.assignableProxy.Get());
        dest_id.assignableProxy.Get().SetTarget(dest_id, dest_id.gameObject);
        Equipment equipment = dest_id.GetEquipment();

        foreach (AssignableSlotInstance slot in equipment.Slots)
        {
            Equippable equippable = slot.assignable as Equippable;
            if ((UnityEngine.Object)equippable != (UnityEngine.Object)null)
            {
                equipment.Equip(equippable);
            }
        }
        Schedulable component7 = src_id.GetComponent <Schedulable>();
        Schedule    schedule   = component7.GetSchedule();

        if (schedule != null)
        {
            schedule.Unassign(component7);
            Schedulable component8 = dest_id.GetComponent <Schedulable>();
            schedule.Assign(component8);
        }
    }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the sequence of attributes of the specified type.
        /// </summary>
        /// <typeparam name="TAttribute">The type of the attribute.</typeparam>
        /// <param name="levels">The attribute levels.</param>
        /// <param name="predicate">The predicate.</param>
        /// <param name="filterByTarget">If set to <c>true</c>, filters by <see cref="MulticastAttribute"/> criteria if <typeparamref name="TAttribute"/> is <see cref="MulticastAttribute"/>.</param>
        /// <returns>The sequence of attributes found.</returns>
        public IEnumerable <TAttribute> GetAll <TAttribute>(AttributeLevels levels, Func <TAttribute, bool> predicate = null, bool filterByTarget = true)
        {
            var attributeSets = GetAllAttributeSets(levels);

            return(FilterAttributeSets(attributeSets, predicate, filterByTarget));
        }
Exemplo n.º 13
0
 /// <summary>
 /// Gets the first attribute of the specified type or null if no such attribute is found.
 /// </summary>
 /// <typeparam name="TAttribute">The type of the attribute.</typeparam>
 /// <param name="levels">The attribute levels.</param>
 /// <param name="predicate">The predicate.</param>
 /// <param name="filterByTarget">If set to <c>true</c>, filters by <see cref="MulticastAttribute"/> criteria if <typeparamref name="TAttribute"/> is <see cref="MulticastAttribute"/>.</param>
 /// <returns>The first attribute found or null.</returns>
 public TAttribute Get <TAttribute>(AttributeLevels levels, Func <TAttribute, bool> predicate = null, bool filterByTarget = true)
 {
     return(GetAll(levels, predicate, filterByTarget).FirstOrDefault());
 }