Esempio n. 1
0
        /// <summary>
        /// Update Humanoid Skeleton based on BodyData.
        /// </summary>
        protected void UpdateSkeleton(ActorFrame actorFrame)
        {
            foreach (HumanBodyBones bone in RokokoHelper.HumanBodyBonesArray)
            {
                if (bone == HumanBodyBones.LastBone)
                {
                    break;
                }
                ActorJointFrame?boneFrame = actorFrame.body.GetBoneFrame(bone);
                if (boneFrame != null)
                {
                    bool shouldUpdatePosition = bone == HumanBodyBones.Hips;

                    Quaternion worldRotation = boneFrame.Value.rotation.ToQuaternion();
                    Vector3    worldPosition = boneFrame.Value.position.ToVector3();

                    // Offset Hip bone
                    if (shouldUpdatePosition && adjustHipHeightBasedOnStudioActor)
                    {
                        worldPosition = new Vector3(worldPosition.x, worldPosition.y - (actorFrame.dimensions.hipHeight - hipHeight), worldPosition.z);
                    }

                    UpdateBone(bone, worldPosition, worldRotation, shouldUpdatePosition, positionSpace, rotationSpace);
                }
            }
        }
Esempio n. 2
0
 public static void UpdateScore_StateChange(ActorFrame actorFrame, string oldState, string newState, ActorFrame acteeFrame)
 {
     foreach (Score score in scores.Values)
     {
         score.UpdateScore_StateChange(actorFrame, oldState, newState, acteeFrame);
     }
 }
Esempio n. 3
0
 public static void UpdateScore_StateChange(ActorFrame actorFrame, string oldState,string newState, ActorFrame acteeFrame)
 {
     foreach (Score score in scores.Values)
     {
         score.UpdateScore_StateChange(actorFrame, oldState,newState, acteeFrame);
     }
 }
Esempio n. 4
0
 public static void UpdateScore_ObjectExists(ActorFrame actorFrame)
 {
     foreach (Score score in scores.Values)
     {
         score.UpdateScore_ObjectExists(actorFrame);
     }
 }
Esempio n. 5
0
 public static void UpdateScore_ObjectExists(ActorFrame actorFrame)
 {
     foreach (Score score in scores.Values)
     {
         score.UpdateScore_ObjectExists(actorFrame);
     }
 }
Esempio n. 6
0
        private void UpdateMaterialColors(ActorFrame actorFrame)
        {
            bodyMaterial.color = actorFrame.color.ToColor();
            meshMaterials[HEAD_TO_MATERIAL_INDEX] = (actorFrame.meta.hasFace) ? faceInvisibleMaterial : bodyMaterial;
            meshRenderer.materials = meshMaterials;

            face?.SetColor(actorFrame.color.ToColor());
        }
Esempio n. 7
0
    /// <summary>
    /// Main process logic of live data
    /// </summary>
    private void ProcessLiveFrame(LiveFrame_v4 frame)
    {
        // Update each actor from live data
        for (int i = 0; i < frame.scene.actors.Length; i++)
        {
            ActorFrame actorFrame = frame.scene.actors[i];

            List <Actor> actorOverrides = GetActorOverride(actorFrame.name);
            // Update custom actors if any
            if (actorOverrides.Count > 0)
            {
                for (int a = 0; a < actorOverrides.Count; a++)
                {
                    actorOverrides[a].UpdateActor(actorFrame);
                }
            }
            // Update default actor
            else if (autoGenerateInputsWhenNoOverridesFound && actors != null)
            {
                actors[actorFrame.name].UpdateActor(actorFrame);
            }
        }

        // Update each prop from live data
        for (int i = 0; i < frame.scene.props.Length; i++)
        {
            PropFrame propFrame = frame.scene.props[i];

            List <Prop> propOverrides = GetPropOverride(propFrame.name);
            // Update custom props if any
            if (propOverrides.Count > 0)
            {
                for (int a = 0; a < propOverrides.Count; a++)
                {
                    propOverrides[a].UpdateProp(propFrame);
                }
            }
            // Update default prop
            else if (autoGenerateInputsWhenNoOverridesFound && props != null)
            {
                props[propFrame.name].UpdateProp(propFrame);
            }
        }

        // Remove all default Actors that doesn't exist in data
        ClearUnusedDefaultInputs(frame);

        // Show default character
        UpdateDefaultActorWhenIdle();

        // Update Hierarchy UI
        uiManager?.UpdateHierarchy(frame);
    }
Esempio n. 8
0
        public void UpdateRow(ActorFrame actorFrame)
        {
            actorPanel.SetActive(true);
            propPanel.SetActive(false);

            profileName           = actorFrame.name;
            profileImage.color    = actorFrame.color.ToColor();
            profileText.text      = actorFrame.name;
            faceImage.color       = actorFrame.meta.hasFace ? Color.white : inactiveColor;
            suitImage.color       = actorFrame.meta.hasBody ? Color.white : inactiveColor;
            leftGloveImage.color  = actorFrame.meta.hasLeftGlove ? Color.white : inactiveColor;
            rightGloveImage.color = actorFrame.meta.hasRightGlove ? Color.white : inactiveColor;
        }
Esempio n. 9
0
 public void UpdateScore_ObjectExists(ActorFrame actorFrame)
 {
     foreach (ScoringRule r in rules)
     {
         if (r.condition.conditionType == ConditionInfo.ConditionType.ObjectExists)
         {
             if (r.actor.MatchFrame(actorFrame, calculateDMs))
             {
                 this.scoreValue += r.deltaValue;
             }
         }
     }
 }
Esempio n. 10
0
 public void UpdateScore_StateChange(ActorFrame actorFrame, string oldState, string newState, ActorFrame acteeFrame)
 {
     foreach (ScoringRule r in rules)
     {
         if (r.condition.conditionType == ConditionInfo.ConditionType.StateChange)
         {
             if (r.actor.MatchFrame(actorFrame, calculateDMs) &&
                 r.actee.MatchFrame(acteeFrame, calculateDMs) &&
                 (r.condition.oldState == "" || r.condition.oldState == oldState) &&
                 r.condition.newState == newState)
             {
                 this.scoreValue += r.deltaValue;
             }
         }
     }
 }
Esempio n. 11
0
        private void SetupInitialOffset()
        {
            ActorStates states = entity.Definition.States;

            int?spawnOffset = states.Labels[SpawnLabel];

            if (spawnOffset == null)
            {
                Log.Error("Unable to find spawn state for actor: ", entity.Definition.Name);
            }
            else
            {
                offset = spawnOffset.Value;
            }

            Frame = states.Frames[offset];
        }
Esempio n. 12
0
        public override void UpdateActor(ActorFrame actorFrame)
        {
            base.UpdateActor(actorFrame);

            bool updateBody = actorFrame.meta.hasBody || actorFrame.meta.hasGloves;

            // Enable/Disable body renderer
            meshRenderer.enabled = updateBody;

            // Update material color and visibility
            UpdateMaterialColors(actorFrame);

            // Enable/Disable face renderer
            if (autoHideFaceWhenInactive)
            {
                face?.gameObject.SetActive(actorFrame.meta.hasFace);
            }
        }
Esempio n. 13
0
        private void ConsumeActorStateFrames(UpperString sprite)
        {
            UpperString                    frames         = ConsumeString();
            int                            ticks          = ConsumeActorFrameTicks();
            ActorFrameProperties           properties     = ConsumeActorFrameKeywordsIfAny();
            Optional <ActorActionFunction> actionFunction = ConsumeActionFunctionIfAny();

            foreach (char frame in frames)
            {
                if (!IsValidFrameLetter(frame))
                {
                    throw MakeException($"Invalid actor frame letter: {frame} (ascii ordinal {(int)frame})");
                }

                ActorFrame actorFrame = new ActorFrame(frameIndex, sprite + frame, ticks, properties, actionFunction);
                currentDefinition.States.Frames.Add(actorFrame);
                frameIndex++;
            }
        }
Esempio n. 14
0
        public void UpdateHierarchy(LiveFrame_v4 dataFrame)
        {
            // Check if UI needs rebuild
            bool forceLayoutUpdate = false;

            // Update each actor from live data
            for (int i = 0; i < dataFrame.scene.actors.Length; i++)
            {
                ActorFrame actorFrame  = dataFrame.scene.actors[i];
                string     profileName = actorFrame.name;

                // If profile doesn't exist, mark for rebuild
                if (forceLayoutUpdate == false && !rows.ContainsKey(profileName))
                {
                    forceLayoutUpdate = true;
                }

                rows[profileName].UpdateRow(actorFrame);
            }

            // Update each prop from live data
            for (int i = 0; i < dataFrame.scene.props.Length; i++)
            {
                PropFrame propFrame   = dataFrame.scene.props[i];
                string    profileName = propFrame.name;

                // If profile doesn't exist, mark for rebuild
                if (forceLayoutUpdate == false && !rows.ContainsKey(profileName))
                {
                    forceLayoutUpdate = true;
                }

                rows[profileName].UpdateRow(propFrame);
            }

            ClearUnusedInputRows(dataFrame);

            if (forceLayoutUpdate)
            {
                LayoutRebuilder.ForceRebuildLayoutImmediate(prefabContainer as RectTransform);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Update Skeleton and Face data based on ActorFrame.
        /// </summary>
        public virtual void UpdateActor(ActorFrame actorFrame)
        {
            if (animator == null || !animator.isHuman)
            {
                return;
            }

            profileName = actorFrame.name;

            bool updateBody = actorFrame.meta.hasBody || actorFrame.meta.hasGloves;

            // Update skeleton from data
            if (updateBody)
            {
                UpdateSkeleton(actorFrame);
            }

            // Update face from data
            if (actorFrame.meta.hasFace)
            {
                face?.UpdateFace(actorFrame.face);
            }
        }
Esempio n. 16
0
            public bool MatchFrame(ActorFrame frame, List<string> forDMs)
            {
                switch (ownerInfo.ownerType)
                {
                    case OwnerInfo.OwnerType.Myself:
                        if (!forDMs.Contains(frame.ownerID))
                        {
                            return false;
                        }
                        break;
                    case OwnerInfo.OwnerType.FriendlyDM:
                        foreach (string forDM in forDMs)
                        {
                            if (StateDB.isHostile(forDM, frame.ownerID))
                            {
                                return false;
                            }
                        }
                        break;
                    case OwnerInfo.OwnerType.HostileDM:
                        foreach (string forDM in forDMs)
                        {
                            if (!StateDB.isHostile(forDM, frame.ownerID))
                            {
                                return false;
                            }
                        }
                        break;
                }

                switch (identifierInfo.identifierType)
                {
                    case IdentifierInfo.IdentifierType.Instance:
                        if (identifierInfo.identifier != frame.objectID)
                        {
                            return false;
                        }
                        break;
                    case IdentifierInfo.IdentifierType.Species:
                        //if (!Genealogy.UnderSpecies( identifierInfo.identifier, frame.speciesName))

                        if (identifierInfo.identifier != frame.speciesName)
                        {
                            return false;
                        }
                        break;
                    case IdentifierInfo.IdentifierType.Any:
                        break;
                }

                switch (locationInfo.locationType)
                {
                    case LocationInfo.LocationType.InZone:
                        if (!frame.activeRegions.Contains(locationInfo.zoneName))
                        {
                            return false;
                        }
                        break;
                    case LocationInfo.LocationType.NotInZone:
                        if (frame.activeRegions.Contains(locationInfo.zoneName))
                        {
                            return false;
                        }
                        break;
                    case LocationInfo.LocationType.Anywhere:
                        break;
                }

                return true;
            }
Esempio n. 17
0
 public void UpdateScore_ObjectExists(ActorFrame actorFrame)
 {
     foreach (ScoringRule r in rules)
     {
         if (r.condition.conditionType == ConditionInfo.ConditionType.ObjectExists)
         {
             if (r.actor.MatchFrame(actorFrame, calculateDMs))
             {
                 this.scoreValue += r.deltaValue;
             }
         }
     }
 }
Esempio n. 18
0
 public void UpdateScore_StateChange(ActorFrame actorFrame, string oldState, string newState, ActorFrame acteeFrame)
 {
     foreach (ScoringRule r in rules)
     {
         if (r.condition.conditionType == ConditionInfo.ConditionType.StateChange)
         {
             if (r.actor.MatchFrame(actorFrame, calculateDMs) &&
                 r.actee.MatchFrame(acteeFrame, calculateDMs) &&
                 (r.condition.oldState == "" || r.condition.oldState == oldState) &&
                 r.condition.newState == newState)
             {
                 this.scoreValue += r.deltaValue;
             }
         }
     }
 }
Esempio n. 19
0
 private void GoToFrame(int index)
 {
     ticksInFrame = 0;
     offset       = index;
     Frame        = entity.Definition.States.Frames[offset];
 }
Esempio n. 20
0
            public bool MatchFrame(ActorFrame frame, List <string> forDMs)
            {
                switch (ownerInfo.ownerType)
                {
                case OwnerInfo.OwnerType.Myself:
                    if (!forDMs.Contains(frame.ownerID))
                    {
                        return(false);
                    }
                    break;

                case OwnerInfo.OwnerType.FriendlyDM:
                    foreach (string forDM in forDMs)
                    {
                        if (StateDB.isHostile(forDM, frame.ownerID))
                        {
                            return(false);
                        }
                    }
                    break;

                case OwnerInfo.OwnerType.HostileDM:
                    foreach (string forDM in forDMs)
                    {
                        if (!StateDB.isHostile(forDM, frame.ownerID))
                        {
                            return(false);
                        }
                    }
                    break;
                }

                switch (identifierInfo.identifierType)
                {
                case IdentifierInfo.IdentifierType.Instance:
                    if (identifierInfo.identifier != frame.objectID)
                    {
                        return(false);
                    }
                    break;

                case IdentifierInfo.IdentifierType.Species:
                    //if (!Genealogy.UnderSpecies( identifierInfo.identifier, frame.speciesName))

                    if (identifierInfo.identifier != frame.speciesName)
                    {
                        return(false);
                    }
                    break;

                case IdentifierInfo.IdentifierType.Any:
                    break;
                }

                switch (locationInfo.locationType)
                {
                case LocationInfo.LocationType.InZone:
                    if (!frame.activeRegions.Contains(locationInfo.zoneName))
                    {
                        return(false);
                    }
                    break;

                case LocationInfo.LocationType.NotInZone:
                    if (frame.activeRegions.Contains(locationInfo.zoneName))
                    {
                        return(false);
                    }
                    break;

                case LocationInfo.LocationType.Anywhere:
                    break;
                }

                return(true);
            }