Exemple #1
0
    protected override void Syncronize()
    {
        CharacterStateInterpolatorData characterStateInterpolatorDatum;
        double num = Interpolation.time;

        if (this.Sample(ref num, out characterStateInterpolatorDatum))
        {
            Character character = base.idMain;
            if (character)
            {
                character.origin     = characterStateInterpolatorDatum.origin;
                character.eyesAngles = characterStateInterpolatorDatum.eyesAngles;
                CharacterStateFlags characterStateFlag = character.stateFlags;
                character.stateFlags = characterStateInterpolatorDatum.state;
                if (!characterStateFlag.Equals(characterStateInterpolatorDatum.state))
                {
                    if (this.once)
                    {
                        character.Signal_State_FlagsChanged(false);
                    }
                    else
                    {
                        character.Signal_State_FlagsChanged(true);
                        this.once = true;
                    }
                }
            }
        }
    }
Exemple #2
0
    protected override void Syncronize()
    {
        CharacterStateInterpolatorData data;
        double time = Interpolation.time;

        if (this.Sample(ref time, out data))
        {
            Character idMain = base.idMain;
            if (idMain != null)
            {
                idMain.origin     = data.origin;
                idMain.eyesAngles = data.eyesAngles;
                CharacterStateFlags stateFlags = idMain.stateFlags;
                idMain.stateFlags = data.state;
                if (!stateFlags.Equals(data.state))
                {
                    if (!this.once)
                    {
                        idMain.Signal_State_FlagsChanged(true);
                        this.once = true;
                    }
                    else
                    {
                        idMain.Signal_State_FlagsChanged(false);
                    }
                }
            }
        }
    }
Exemple #3
0
    public static CharacterStateFlags ReadCharacterStateFlags(this BitStream stream)
    {
        CharacterStateFlags characterStateFlag = new CharacterStateFlags();

        characterStateFlag.flags = stream.ReadUInt16();
        return(characterStateFlag);
    }
Exemple #4
0
 internal void HandleChangedStateFlags(CharacterStateFlags flags, bool notFromLoading)
 {
     if ((((byte)(this.caps & Caps.BindStateFlags)) == 2) && (!this._lastFlags.HasValue || !this._lastFlags.Value.Equals(flags)))
     {
         this.BindStateFlags(flags, !notFromLoading ? Reason.Initialization : Reason.Explicit);
         this._lastFlags = new CharacterStateFlags?(flags);
     }
 }
Exemple #5
0
 internal void HandleChangedStateFlags(CharacterStateFlags flags, bool notFromLoading)
 {
     if ((byte)(this.caps & ItemModRepresentation.Caps.BindStateFlags) == 2 && (!this._lastFlags.HasValue || !this._lastFlags.Value.Equals(flags)))
     {
         this.BindStateFlags(flags, (!notFromLoading ? ItemModRepresentation.Reason.Initialization : ItemModRepresentation.Reason.Explicit));
         this._lastFlags = new CharacterStateFlags?(flags);
     }
 }
Exemple #6
0
    public void SetGoals(Vector3 pos, Angle2 rot, CharacterStateFlags state, double timestamp)
    {
        CharacterStateInterpolatorData characterStateInterpolatorDatum = new CharacterStateInterpolatorData();

        characterStateInterpolatorDatum.origin     = pos;
        characterStateInterpolatorDatum.eyesAngles = rot;
        characterStateInterpolatorDatum.state      = state;
        base.SetGoals(ref characterStateInterpolatorDatum, ref timestamp);
    }
Exemple #7
0
    public void SetGoals(Vector3 pos, Angle2 rot, CharacterStateFlags state, double timestamp)
    {
        CharacterStateInterpolatorData data;

        data.origin     = pos;
        data.eyesAngles = rot;
        data.state      = state;
        base.SetGoals(ref data, ref timestamp);
    }
Exemple #8
0
    protected CharacterStateFlags GetCharacterStateFlags()
    {
        if (this.CheckParent() && this._parentMain is Character)
        {
            CharacterStateFlags characterStateFlag = ((Character)this._parentMain).stateFlags;
            this.lastCharacterStateFlags = new CharacterStateFlags?(characterStateFlag);
            return(characterStateFlag);
        }
        CharacterStateFlags?nullable = this.lastCharacterStateFlags;

        return(!nullable.HasValue ? new CharacterStateFlags() : nullable.Value);
    }
Exemple #9
0
    protected CharacterStateFlags GetCharacterStateFlags()
    {
        if (this.CheckParent() && (this._parentMain is Character))
        {
            CharacterStateFlags stateFlags = ((Character)this._parentMain).stateFlags;
            this.lastCharacterStateFlags = new CharacterStateFlags?(stateFlags);
            return(stateFlags);
        }
        CharacterStateFlags?lastCharacterStateFlags = this.lastCharacterStateFlags;

        return(!lastCharacterStateFlags.HasValue ? new CharacterStateFlags() : lastCharacterStateFlags.Value);
    }
Exemple #10
0
    protected void Mods(byte[] data)
    {
        this.ClearMods();
        uLink.BitStream stream = new uLink.BitStream(data, false);
        byte            num    = stream.ReadByte();

        if (num > 0)
        {
            CharacterStateFlags characterStateFlags = this.GetCharacterStateFlags();
            for (int i = 0; i < num; i++)
            {
                ItemModDataBlock byUniqueID = (ItemModDataBlock)DatablockDictionary.GetByUniqueID(stream.ReadInt32());
                this._itemMods.InstallMod(i, this, byUniqueID, characterStateFlags);
                this._modFlags |= byUniqueID.modFlag;
            }
        }
    }
Exemple #11
0
    protected virtual void StateSignalReceive(Character character, bool treatedAsFirst)
    {
        CharacterStateFlags characterStateFlag = character.stateFlags;

        if (this.lastCharacterStateFlags.HasValue && this.lastCharacterStateFlags.Value.Equals(characterStateFlag))
        {
            return;
        }
        this.lastCharacterStateFlags = new CharacterStateFlags?(characterStateFlag);
        for (int i = 0; i < 5; i++)
        {
            if (this._itemMods[i].representation)
            {
                ItemRepresentation.ItemModPair item = this._itemMods[i];
                item.representation.HandleChangedStateFlags(characterStateFlag, !treatedAsFirst);
            }
        }
    }
Exemple #12
0
 internal void Initialize(ItemRepresentation itemRep, int modSlot, CharacterStateFlags flags)
 {
     if (this._modSlot == -1)
     {
         if (itemRep == null)
         {
             throw new ArgumentOutOfRangeException("itemRep", itemRep, "!itemRep");
         }
         if ((modSlot < 0) || (modSlot >= 5))
         {
             throw new ArgumentOutOfRangeException("modSlot", modSlot, "modSlot<0||modSlot>=MAX_SUPPORTED_ITEM_MODS");
         }
         this._itemRep = itemRep;
         this._modSlot = modSlot;
         if (((byte)(this.caps & Caps.Initialize)) == 1)
         {
             try
             {
                 this.Initialize();
             }
             catch (Exception)
             {
                 this._itemRep = null;
                 this._modSlot = -1;
                 throw;
             }
         }
         this.HandleChangedStateFlags(flags, false);
     }
     else
     {
         if (this._modSlot == -2)
         {
             throw new InvalidOperationException("This ItemModRepresentation has been destroyed");
         }
         if ((itemRep != this._itemRep) || (((modSlot < 0) && (modSlot < 5)) && (modSlot != this._modSlot)))
         {
             object[] args = new object[] { this._itemRep, this._modSlot, itemRep, modSlot };
             throw new InvalidOperationException(string.Format("The ItemModRepresentation was already initialized with {{\"item\":\"{0}\",\"slot\":{1}}} and cannot be re-initialized to use {{\"item\":\"{2|\",\"slot\":{3}}}", args));
         }
     }
 }
 protected virtual void BindStateFlags(CharacterStateFlags flags, ItemModRepresentation.Reason reason)
 {
 }
 public static void Serialize(this BitStream stream, ref CharacterStateFlags v)
 {
     stream.Serialize<ushort>(ref v.flags, new object[0]);
 }
Exemple #15
0
 protected virtual void BindStateFlags(CharacterStateFlags flags, ItemModRepresentation.Reason reason)
 {
 }
Exemple #16
0
 protected override void BindStateFlags(CharacterStateFlags flags, ItemModRepresentation.Reason reason)
 {
     base.BindStateFlags(flags, reason);
     base.SetOn(flags.laser, reason);
 }
 public static void WriteCharacterStateFlags(this BitStream stream, CharacterStateFlags v)
 {
     stream.WriteUInt16(v.flags);
 }
Exemple #18
0
 protected virtual void BindStateFlags(CharacterStateFlags flags, Reason reason)
 {
 }
Exemple #19
0
    private void Update()
    {
        CharacterStateFlags stateFlags;
        Weights             lastHeadingWeights;

        Facepunch.Movement.State walk;
        float  lastUnitScale;
        double deltaTime;

        this.CalculateVelocity();
        Character idMain = base.idMain;
        bool      flag   = (bool)idMain;

        if (flag)
        {
            stateFlags = idMain.stateFlags;
        }
        else
        {
            stateFlags = new CharacterStateFlags();
        }
        bool isJumping = !stateFlags.grounded;
        bool focus     = stateFlags.focus;
        bool crouch    = stateFlags.crouch;

        lastHeadingWeights.idle = 0f;
        if (this.movementNormal.x > 0f)
        {
            lastHeadingWeights.east = this.movementNormal.x;
            lastHeadingWeights.west = 0f;
        }
        else if (this.movementNormal.x < 0f)
        {
            lastHeadingWeights.east = 0f;
            lastHeadingWeights.west = -this.movementNormal.x;
        }
        else
        {
            lastHeadingWeights.east = lastHeadingWeights.west = 0f;
        }
        if (this.movementNormal.y > 0f)
        {
            lastHeadingWeights.north = this.movementNormal.y;
            lastHeadingWeights.south = 0f;
        }
        else if (this.movementNormal.y < 0f)
        {
            lastHeadingWeights.north = 0f;
            lastHeadingWeights.south = -this.movementNormal.y;
        }
        else
        {
            lastHeadingWeights.north = lastHeadingWeights.south = 0f;
        }
        if ((this.movementNormal.y == 0f) && (this.movementNormal.x == 0f))
        {
            lastHeadingWeights = this.lastHeadingWeights;
        }
        lastHeadingWeights.idle = 0f;
        this.lastHeadingWeights = lastHeadingWeights;
        if (isJumping)
        {
            walk = Facepunch.Movement.State.Walk;
        }
        else if (crouch)
        {
            walk = Facepunch.Movement.State.Crouch;
        }
        else if (stateFlags.sprint && (this.speedPrecise >= this.movement.configuration.runSpeed))
        {
            walk = Facepunch.Movement.State.Run;
        }
        else
        {
            walk = Facepunch.Movement.State.Walk;
        }
        string animationGroupName = this.itemHolder.animationGroupName;

        if (this.idealGroupName != animationGroupName)
        {
            this.idealGroupName = animationGroupName;
            if (animationGroupName != null)
            {
                animationGroupName = animationGroupName;
            }
            else
            {
                animationGroupName = this.animationTrait.defaultGroupName;
            }
            int?nullable = this.movement.configuration.GroupIndex(animationGroupName);
            if (!nullable.HasValue)
            {
                Debug.LogWarning("Could not find group name " + this.idealGroupName);
                this.usingGroupName = this.animationTrait.defaultGroupName;
                int?nullable2 = this.movement.configuration.GroupIndex(this.usingGroupName);
                this.usingGroupIndex = !nullable2.HasValue ? 0 : nullable2.Value;
            }
            else
            {
                this.usingGroupName  = this.idealGroupName;
                this.usingGroupIndex = nullable.Value;
            }
        }
        int usingGroupIndex = this.usingGroupIndex;

        if (!stateFlags.slipping)
        {
            deltaTime           = Time.deltaTime;
            this.movement.state = walk;
            this.movement.group = usingGroupIndex;
            lastUnitScale       = this.movement.UpdateWeights(Time.deltaTime, isJumping, !flag || stateFlags.movement);
        }
        else
        {
            deltaTime     = -Time.deltaTime;
            lastUnitScale = this.lastUnitScale;
        }
        this.wasAirborne   = isJumping;
        this.lastUnitScale = lastUnitScale;
        if (!double.IsNaN(this.speedPrecise) && !double.IsInfinity(this.speedPrecise))
        {
            float positionTime = this.positionTime;
            this.positionTime = (float)((this.positionTime + Math.Abs((double)((lastUnitScale * this.speedPrecise) * deltaTime))) % 1.0);
            if (this.positionTime < 0f)
            {
                this.positionTime++;
            }
            else if (float.IsNaN(this.positionTime) || float.IsInfinity(this.positionTime))
            {
                this.positionTime = positionTime;
            }
            this.movement.configuration.OffsetTime(this.positionTime, out this.times);
        }
        float angle = !flag ? -base.transform.eulerAngles.x : idMain.eyesPitch;

        this.movement.SetWeights(this.animation, ref lastHeadingWeights, ref this.times, angle);
    }
 public static void WriteCharacterStateFlags(this BitStream stream, CharacterStateFlags v)
 {
     stream.WriteUInt16(v.flags);
 }
 public static void Serialize(this BitStream stream, ref CharacterStateFlags v)
 {
     stream.Serialize <ushort>(ref v.flags, new object[0]);
 }
 public static CharacterStateFlags ReadCharacterStateFlags(this BitStream stream)
 {
     CharacterStateFlags characterStateFlag = new CharacterStateFlags();
     characterStateFlag.flags = stream.ReadUInt16();
     return characterStateFlag;
 }
 internal void Initialize(ItemRepresentation itemRep, int modSlot, CharacterStateFlags flags)
 {
     if (this._modSlot != -1)
     {
         if (this._modSlot == -2)
         {
             throw new InvalidOperationException("This ItemModRepresentation has been destroyed");
         }
         if (itemRep != this._itemRep || modSlot < 0 && modSlot < 5 && modSlot != this._modSlot)
         {
             throw new InvalidOperationException(string.Format("The ItemModRepresentation was already initialized with {{\"item\":\"{0}\",\"slot\":{1}}} and cannot be re-initialized to use {{\"item\":\"{2|\",\"slot\":{3}}}", new object[] { this._itemRep, this._modSlot, itemRep, modSlot }));
         }
     }
     else
     {
         if (!itemRep)
         {
             throw new ArgumentOutOfRangeException("itemRep", itemRep, "!itemRep");
         }
         if (modSlot < 0 || modSlot >= 5)
         {
             throw new ArgumentOutOfRangeException("modSlot", (object)modSlot, "modSlot<0||modSlot>=MAX_SUPPORTED_ITEM_MODS");
         }
         this._itemRep = itemRep;
         this._modSlot = modSlot;
         if ((byte)(this.caps & ItemModRepresentation.Caps.Initialize) == 1)
         {
             try
             {
                 this.Initialize();
             }
             catch (Exception exception)
             {
                 this._itemRep = null;
                 this._modSlot = -1;
                 throw;
             }
         }
         this.HandleChangedStateFlags(flags, false);
     }
 }
Exemple #24
0
 protected override void BindStateFlags(CharacterStateFlags flags, ItemModRepresentation.Reason reason)
 {
     base.BindStateFlags(flags, reason);
     base.SetOn(flags.lamp, reason);
 }
Exemple #25
0
 private void InstallMod(ref ItemModPair to, int slot, ItemModDataBlock datablock, CharacterStateFlags flags)
 {
     to.dataBlock = datablock;
     if (to.representation != null)
     {
         this.KillModRep(ref to.representation, false);
     }
     if (to.dataBlock.hasModRepresentation && to.dataBlock.AddModRepresentationComponent(base.gameObject, out to.representation))
     {
         to.bindState = BindState.None;
         to.representation.Initialize(this, slot, flags);
         if (to.representation != null)
         {
             if (this.worldModels)
             {
                 this._itemMods.BindAsProxy(slot, this);
             }
         }
         else
         {
             to.bindState      = BindState.Vacant;
             to.representation = null;
         }
     }
 }
 internal void HandleChangedStateFlags(CharacterStateFlags flags, bool notFromLoading)
 {
     if ((byte)(this.caps & ItemModRepresentation.Caps.BindStateFlags) == 2 && (!this._lastFlags.HasValue || !this._lastFlags.Value.Equals(flags)))
     {
         this.BindStateFlags(flags, (!notFromLoading ? ItemModRepresentation.Reason.Initialization : ItemModRepresentation.Reason.Explicit));
         this._lastFlags = new CharacterStateFlags?(flags);
     }
 }
Exemple #27
0
        public void InstallMod(int slotNumber, ItemRepresentation owner, ItemModDataBlock datablock, CharacterStateFlags flags)
        {
            switch (slotNumber)
            {
            case 0:
            {
                owner.InstallMod(ref this.a, 0, datablock, flags);
                break;
            }

            case 1:
            {
                owner.InstallMod(ref this.b, 1, datablock, flags);
                break;
            }

            case 2:
            {
                owner.InstallMod(ref this.c, 2, datablock, flags);
                break;
            }

            case 3:
            {
                owner.InstallMod(ref this.d, 3, datablock, flags);
                break;
            }

            case 4:
            {
                owner.InstallMod(ref this.e, 4, datablock, flags);
                break;
            }

            default:
            {
                throw new IndexOutOfRangeException();
            }
            }
        }