Esempio n. 1
0
 public MyCondition(IMyVariableStorage <T> storage, MyOperation operation, string leftSideStorage, string rightSideStorage)
 {
     Debug.Assert(storage != null, "Variable storage must not be null.");
     m_storage          = storage;
     m_operation        = operation;
     m_leftSideStorage  = MyStringId.GetOrCompute(leftSideStorage);
     m_rightSideStorage = MyStringId.GetOrCompute(rightSideStorage);
 }
Esempio n. 2
0
 public MyCondition(IMyVariableStorage <T> storage, MyOperation operation, T leftSideValue, T rightSideValue)
 {
     // Debug.Assert(storage != null, "Variable storage must not be null."); // the storage can be null here
     m_storage          = storage;
     m_operation        = operation;
     m_leftSideStorage  = MyStringId.NullOrEmpty;
     m_rightSideStorage = MyStringId.NullOrEmpty;
     m_leftSideValue    = leftSideValue;
     m_rightSideValue   = rightSideValue;
 }
Esempio n. 3
0
 public unsafe void BlendWeight(ref float weight, MyCharacterBone bone, IMyVariableStorage <float> controllerVariables)
 {
     if (this.m_boneIndexToData.Length > bone.Index)
     {
         float    num;
         float    num2;
         BoneData data = this.m_boneIndexToData[bone.Index];
         if (!controllerVariables.GetValue(this.m_defautlBlendTimeId, out this.m_defaultBlendTime))
         {
             this.m_defaultBlendTime = 2.5f;
         }
         if (!controllerVariables.GetValue(data.WeightId, out num) || (num < 0f))
         {
             num = -1f;
         }
         if (!controllerVariables.GetValue(data.BlendTimeId, out num2) || (num2 < 0f))
         {
             num2 = -1f;
         }
         if ((num < 0f) || (num2 < 0f))
         {
             float       maxValue = float.MaxValue;
             float       num6     = float.MaxValue;
             LayerData[] layers   = data.Layers;
             int         index    = 0;
             while (true)
             {
                 float num8;
                 float num9;
                 if (index >= layers.Length)
                 {
                     if (num < 0f)
                     {
                         if (maxValue == float.MaxValue)
                         {
                             return;
                         }
                         num = maxValue;
                     }
                     if (num2 < 0f)
                     {
                         num2 = (num6 == float.MaxValue) ? this.m_defaultBlendTime : num6;
                     }
                     break;
                 }
                 LayerData data2 = layers[index];
                 if (controllerVariables.GetValue(data2.LayerId, out num8))
                 {
                     maxValue = Math.Min(maxValue, num8);
                 }
                 if (controllerVariables.GetValue(data2.LayerBlendTimeId, out num9))
                 {
                     num6 = Math.Min(num6, num9);
                 }
                 index++;
             }
         }
         double totalMilliseconds = TIMER.ElapsedTimeSpan.TotalMilliseconds;
         data.BlendTimeMs = num2 * 1000f;
         if (num != data.TargetWeight)
         {
             data.StartedMs = totalMilliseconds;
             BoneData *dataPtr1 = (BoneData *)ref data;
             dataPtr1->StartingWeight = (data.PrevWeight == -1f) ? weight : data.PrevWeight;
             data.TargetWeight        = num;
         }
         double amount = MathHelper.Clamp((double)((totalMilliseconds - data.StartedMs) / data.BlendTimeMs), (double)0.0, (double)1.0);
         weight          = (float)MathHelper.Lerp((double)data.StartingWeight, (double)data.TargetWeight, amount);
         data.PrevWeight = weight;
         this.m_boneIndexToData[bone.Index] = data;
     }
 }