Example #1
0
        internal void SetWantState(WantStates state)
        {
            int curState = this.GetWantFromState(state);

            if (curState == 0)
            {
                return;
            }

            if (this.WantMod != null)
            {
                this.WantMod.Remove();
                this.WantMod = null;
            }

            int lastState = this.GetWantFromState(this.LastWantState);
            var prev      = this.LastWantState;

            this.LastWantState = state;

            if (curState > 0)
            {
                this.WantMod = this.Values.WantEnabled.AddModifier(null, CameraValueModifier.ModifierTypes.Add, 1.0, false);
            }
            else
            {
                this.WantMod = this.Values.WantDisabled.AddModifier(null, CameraValueModifier.ModifierTypes.Add, 1.0, false);
            }
        }
Example #2
0
        internal CameraValueModifier AddModifier(CameraState fromState, CameraValueModifier.ModifierTypes type, double amount, bool autoRemoveOnLeaveState = true, long autoRemoveDelay = 0)
        {
            if ((this.Flags & CameraValueFlags.NoModifiers) != CameraValueFlags.None)
            {
                return(null);
            }

            var  mod   = new CameraValueModifier(this, fromState, type, amount, autoRemoveOnLeaveState, autoRemoveDelay);
            bool added = false;

            for (int i = 0; i < this.Modifiers.Count; i++)
            {
                var m = this.Modifiers[i];
                if (m.Priority > mod.Priority)
                {
                    this.Modifiers.Insert(i, mod);
                    added = true;
                    break;
                }
            }

            if (!added)
            {
                this.Modifiers.Add(mod);
            }

            if (mod.AutoRemove && fromState != null)
            {
                fromState.RemoveModifiersOnLeave.Add(mod);
            }

            this.UpdatedCountWhenDisabled = 0;

            return(mod);
        }
 internal void RemoveModifier(CameraValueModifier mod)
 {
     if (mod.Owner == this)
     {
         if (Modifiers.Remove(mod))
         {
             UpdatedCountWhenDisabled = 0;
         }
     }
 }
        internal void SetWantState(WantStates state)
        {
            var curState = GetWantFromState(state);

            if (curState == 0)
            {
                return;
            }

            if (WantMod != null)
            {
                WantMod.Remove();
                WantMod = null;
            }

            var lastState = GetWantFromState(LastWantState);
            var prev      = LastWantState;

            LastWantState = state;

            WantMod = curState > 0
                ? Values.WantEnabled.AddModifier(null, CameraValueModifier.ModifierTypes.Add, 1.0, false)
                : Values.WantDisabled.AddModifier(null, CameraValueModifier.ModifierTypes.Add, 1.0, false);
        }