Exemplo n.º 1
0
        public void ReadFromFile(BinaryReader reader)
        {
            int    poolLength = reader.ReadInt32();
            string pool       = new string(reader.ReadChars(poolLength));

            int hashesLength = reader.ReadInt32();

            definitions = new ActorDefinition[hashesLength];

            for (int i = 0; i != hashesLength; i++)
            {
                definitions[i] = new ActorDefinition(reader);
                int pos = definitions[i].NamePos;
                definitions[i].name = pool.Substring(pos, pool.IndexOf('\0', pos) - pos);
            }

            unkSector = new ActorExtraData(reader);

            items = new ActorItem[unkSector.ItemCount];

            for (int i = 0; i != unkSector.ItemCount; i++)
            {
                items[i] = new ActorItem(reader);
            }

            unk16 = reader.ReadInt32();

            //if (unk16 != 0)
            //throw new Exception("UNK16 is not 0. Message Greavesy with this message and the name of the SDS you tried to read");
        }
Exemplo n.º 2
0
        private static ActorDefinition CreatePlayerPawn(ActorDefinition actorBase)
        {
            ActorDefinition playerPawn = new ActorDefinition("PLAYERPAWN", actorBase);

            playerPawn.ActorType.Set(ActorType.Player);
            playerPawn.Flags.Set(ActorFlagType.CanPass, true);
            playerPawn.Flags.Set(ActorFlagType.CanPushWalls, true);
            playerPawn.Flags.Set(ActorFlagType.Dropoff, true);
            playerPawn.Flags.Set(ActorFlagType.FloorClip, true);
            playerPawn.Flags.Set(ActorFlagType.Friendly, true);
            playerPawn.Flags.Set(ActorFlagType.NoBlockMonst, true);
            playerPawn.Flags.Set(ActorFlagType.NotDMatch, true);
            playerPawn.Flags.Set(ActorFlagType.Pickup, true);
            playerPawn.Flags.Set(ActorFlagType.Shootable, true);
            playerPawn.Flags.Set(ActorFlagType.SlidesOnWalls, true);
            playerPawn.Flags.Set(ActorFlagType.Solid, true);
            playerPawn.Flags.Set(ActorFlagType.Telestomp, true);
            playerPawn.Flags.Set(ActorFlagType.WindThrust, true);
            playerPawn.Properties.Health                        = 100;
            playerPawn.Properties.Height                        = 56;
            playerPawn.Properties.Mass                          = 100;
            playerPawn.Properties.PainChance.Value              = 255;
            playerPawn.Properties.Radius                        = 16;
            playerPawn.Properties.Speed                         = 1;
            playerPawn.Properties.PlayerAttackZOffset           = 8;
            playerPawn.Properties.PlayerDamageScreenColor.Color = new Color(1, 0, 0);
            playerPawn.Properties.PlayerFlechetteType           = "ARTIPOISONBAG3".AsUpper();
            playerPawn.Properties.PlayerSoundClass              = "PLAYER".AsUpper();

            return(playerPawn);
        }
Exemplo n.º 3
0
        private ActorDefinition ConsumeActorHeader()
        {
            UpperString name = ConsumeString();

            ActorDefinition parent = DecorateManager.BaseActorDefinition;

            if (ConsumeIf(':'))
            {
                UpperString parentName = ConsumeString();
                Optional <ActorDefinition> parentOpt = LookupActor(parentName);
                if (parentOpt)
                {
                    parent = parentOpt.Value;
                }
                else
                {
                    throw MakeException($"Unable to find parent {parentName} for actor {name}");
                }
            }

            if (ConsumeIf("replaces"))
            {
                ConsumeString();
                throw MakeException("Unsupported 'replaces' keyword temporarily!");
            }

            int?editorId = ConsumeIfInt();

            return(new ActorDefinition(name, parent, editorId));
        }
        /// <summary>
        /// Checks for mouse events in this frame, moving created objects and notifying "DragAndDrop" of state changes.
        /// </summary>
        /// <param name="inScene">true if being called from OnSceneGUI, otherwise false.</param>
        private void ProcessDragEvents(bool inScene)
        {
            EventType eventType = Event.current.type;

            //Don't try and make/move the object when we are not focused in the scene.
            if (inScene && eventType == EventType.DragUpdated)
            {
                if (DragAndDrop.GetGenericData("ActorDefinition") != null)
                {
                    ActorDefinition draggedObj = (ActorDefinition)DragAndDrop.GetGenericData("ActorDefinition");

                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy; // show a drag-add icon on the mouse cursor

                    Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);

                    //We have entered the scene. Create the forgelight object at our current position.
                    if (draggedObj.instantiatedGameObject == null)
                    {
                        draggedObj.instantiatedGameObject = ForgelightExtension.Instance.ZoneManager.ZoneObjectFactory.CreateForgelightObject(draggedObj.forgelightGame, draggedObj.actorDefinition, ray.GetPoint(objectCreationDistance), Quaternion.identity);
                    }

                    else
                    {
                        draggedObj.instantiatedGameObject.transform.position = ray.GetPoint(objectCreationDistance);
                    }

                    Selection.activeGameObject = draggedObj.instantiatedGameObject;
                }
            }

            else if (eventType == EventType.DragPerform)
            {
                DragAndDrop.AcceptDrag();
            }
        }
Exemplo n.º 5
0
 public CreatePropNode()
     : base(ResourceType, ResourceTag)
 {
     this.mPropActor = null;
     this.mPropParam = null;
     this.mPropKey = new RK();
 }
Exemplo n.º 6
0
        public ActorBehaviour SpawnActor(ActorType actorType, Vector2Int position, bool isBoss = false)
        {
            ActorBehaviour instantiatedActor = _actorBehaviourFactory.Create();

            instantiatedActor.name = actorType.ToString();
            ActorData actorData = instantiatedActor.ActorData;

            actorData.ActorType = actorType;
            actorData.IsBoss    = isBoss;

            ActorDefinition actorDefinition = _gameConfig.ActorConfig.GetDefinition(actorType);

            instantiatedActor.GetComponent <SpriteRenderer>().sprite = actorDefinition.Sprite;
            actorData.WeaponWeld      = _rng.Choice(actorDefinition.WeaponPool);
            actorData.SwordsFromSkill = actorDefinition.SwordsFromSkill;
            actorData.VisionRayLength = actorDefinition.VisionRayLength;
            actorData.EnergyGain      = actorDefinition.EnergyGain;
            actorData.Team            = actorDefinition.Team;
            actorData.MaxHealth       = actorDefinition.MaxHealth;
            actorData.Health          = actorDefinition.MaxHealth;
            actorData.Accuracy        = actorDefinition.Accuracy;
            actorData.XpGiven         = actorDefinition.XpGiven;
            actorData.Level           = actorDefinition.InitialLevel;
            actorData.Traits          = actorDefinition.InitialTraits.ToArray().ToList();
            actorData.AiTraits        = actorDefinition.AiTraits.ToArray().ToList();

            Vector2Int freePosition = GetPositionToPlaceActor(position);

            actorData.LogicalPosition = freePosition;
            instantiatedActor.RefreshWorldPosition();
            _gameContext.Actors.Add(instantiatedActor);
            instantiatedActor.gameObject.SetActive(true);
            return(instantiatedActor);
        }
Exemplo n.º 7
0
 public ActorCommand(ActorSuffix suffix,
                     ActorDefinition newValue)
 {
     this.mSuffix = suffix;
     this.mOldVal = suffix.mActor.GetValue();
     this.mNewVal = newValue;
     this.mLabel  = "Set Actor of Actor Suffix";
 }
Exemplo n.º 8
0
        private static ActorDefinition CreatePowerup(ActorDefinition inventory)
        {
            ActorDefinition powerup = new ActorDefinition("POWERUP", inventory);

            powerup.ActorType.Set(ActorType.Powerup);

            return(powerup);
        }
Exemplo n.º 9
0
 public ActorOperationNode(
     JazzActorOperationNode.ActorOperation operation)
     : base(ResourceType, ResourceTag)
 {
     this.mActor = null;
     this.mOperation = operation;
     this.mOperand = 0;
 }
Exemplo n.º 10
0
        private static ActorDefinition CreateAmmo(ActorDefinition inventory)
        {
            ActorDefinition ammo = new ActorDefinition("AMMO", inventory);

            ammo.ActorType.Set(ActorType.Ammo);
            ammo.Properties.InventoryPickupSound = "MISC/ARMOR_PKUP".AsUpper();

            return(ammo);
        }
Exemplo n.º 11
0
        public override void Register(ProcessDefinition pd, List <WorkflowBlock> blocks)
        {
            base.Register(pd, blocks);

            var actor = ActorDefinition.Create(string.Format("LegalEntitySigns_{0}", Name), "BudgetItemIsLegalEntityNeedSigns", Name);

            pd.Actors.Add(actor);
            this["_actorRestrictions"] = actor;
        }
Exemplo n.º 12
0
        private void ConsumeActorDefinition()
        {
            Consume("actor");
            currentDefinition = ConsumeActorHeader();
            Consume('{');
            InvokeUntilAndConsume('}', ConsumeActorBodyComponent);

            Definitions.Add(currentDefinition);
            nameToDefinition[currentDefinition.Name] = currentDefinition;
        }
Exemplo n.º 13
0
        private static ActorDefinition CreateTeleportDestination(ActorDefinition actorBase)
        {
            ActorDefinition teleportDest = new ActorDefinition("TELEPORTDEST", actorBase, 14);

            teleportDest.ActorType.Set(ActorType.TeleportDestination);
            teleportDest.Flags.Set(ActorFlagType.DontSplash, true);
            teleportDest.Flags.Set(ActorFlagType.NoBlockmap, true);

            return(teleportDest);
        }
Exemplo n.º 14
0
        private static void ResetCoreDefinitions()
        {
            AddDefinitions(DefaultDefinitionFactory.CreateAllDefaultDefinitions());

            missingActorDefinition = nameToDefinition.Find(missingActorName).Value;
            if (missingActorDefinition == null)
            {
                throw new NullReferenceException($"Core definition for unknown '{missingActorName}' missing");
            }
        }
Exemplo n.º 15
0
 public AnimationNode(uint nodeType, string nodeTag)
     : base(nodeType, nodeTag)
 {
     this.mFlags = JazzAnimationFlags.Default;
     this.mPriority = JazzChunk.AnimationPriority.Unset;
     this.mBlendInTime = 0;
     this.mBlendOutTime = 0;
     this.mSpeed = 1;
     this.mActor = null;
     this.mTimingPriority = JazzChunk.AnimationPriority.Unset;
 }
Exemplo n.º 16
0
 public ActorSuffix(SlotBuilder sb,
                    ActorDefinition actor, ParamDefinition param)
 {
     if (sb == null)
     {
         throw new ArgumentNullException("sb");
     }
     this.mSB    = sb;
     this.mActor = new RefToActor(sb.mScene, actor);
     this.mParam = new RefToParam(sb.mScene, param);
 }
Exemplo n.º 17
0
        private static ActorDefinition CreateKey(ActorDefinition inventory)
        {
            ActorDefinition key = new ActorDefinition("KEY", inventory);

            key.ActorType.Set(ActorType.Key);
            key.Flags.Set(ActorFlagType.DontGib, true);
            key.Flags.Set(ActorFlagType.InventoryInterHubStrip, true);
            key.Properties.InventoryPickupSound = "MISC/K_PICKUP".AsUpper();

            return(key);
        }
Exemplo n.º 18
0
 public DefActor(ActorDefinition actor, StateMachineScene scene)
 {
     if (actor == null)
     {
         throw new ArgumentNullException("actor");
     }
     if (scene == null)
     {
         throw new ArgumentNullException("scene");
     }
     this.mActor = actor;
     this.mScene = scene;
 }
Exemplo n.º 19
0
        private static ActorDefinition CreateInventory(ActorDefinition actorBase)
        {
            ActorDefinition inventory = new ActorDefinition("INVENTORY", actorBase);

            inventory.ActorType.Set(ActorType.Inventory);
            inventory.Properties.InventoryAmount         = 1;
            inventory.Properties.InventoryInterHubAmount = 1;
            inventory.Properties.InventoryMaxAmount      = 1;
            inventory.Properties.InventoryPickupSound    = "MISC/I_PKUP".AsUpper();
            inventory.Properties.InventoryPickupMessage  = "$TXT_DEFAULTPICKUPMSG".AsUpper();
            inventory.Properties.InventoryUseSound       = "MISC/INVUSE".AsUpper();

            return(inventory);
        }
Exemplo n.º 20
0
        private Entity Spawn(ActorDefinition definition, Vec3F position, BitAngle angle)
        {
            Sector sector = world.Geometry.BspTree.Sector(position);
            Entity entity = new Entity(nextEntityID++, definition, position, angle, sector, this);

            entity.node = Entities.AddLast(entity);

            if (entity.Definition.ActorType.SpawnPoint)
            {
                spawnPoints.Add(entity);
            }

            return(entity);
        }
Exemplo n.º 21
0
        public ActorStates(ActorDefinition owner, ActorStates other, UpperString parentName) :
            this(owner)
        {
            foreach (ActorFrame frame in other.Frames)
            {
                ActorFrame newFrame = new ActorFrame(frame);
                Frames.Add(newFrame);
            }

            Labels = new ActorStateLabels(other.Labels, parentName);

            // Note: We are not copying flow overrides because they should be
            // specific to their object definition.
        }
Exemplo n.º 22
0
        public override void Register(ProcessDefinition pd, List <WorkflowBlock> blocks)
        {
            base.Register(pd, blocks);

            bool isFinal = this["Commands"] == null
                ? true :
                           (this["Commands"] as List <SimpleCommand>).Count == 0;

            //activity
            var c = ActivityDefinition.Create(Name, Name, TryCast <bool>("Initial", false), isFinal, true, true);

            if (c.IsInitial)
            {
                c.AddAction(ActionDefinitionReference.Create("CheckDocumentType", "0", string.Empty));
            }

            //actions
            if (this["AllowEdit"] is bool)
            {
                c.AddAction(ActionDefinitionReference.Create("SetDocumentEditable", "1", this["AllowEdit"].ToString()));
            }

            c.AddAction(ActionDefinitionReference.Create("SetDocumentState", "2", string.Empty));
            c.AddAction(ActionDefinitionReference.Create("UpdateHistory", "3", string.Empty));
            c.AddPreExecutionAction(ActionDefinitionReference.Create("WriteHistory", "0", string.Empty));

            pd.Activities.Add(c);
            this["_currentActivity"] = c;

            //actor
            var users = this["Users"] as string;

            if (!string.IsNullOrWhiteSpace(users))
            {
                var actor = ActorDefinition.Create(string.Format("Actor{0}", Name), "CheckUsers", users);
                pd.Actors.Add(actor);
                this["_actorRestrictions"] = actor;
            }
            else if (c.IsInitial)
            {
                var actor = pd.Actors.FirstOrDefault(a => a.Name == "Author");
                if (actor == null)
                {
                    actor = ActorDefinition.Create("Author", "Author", null);
                    pd.Actors.Add(actor);
                }
                this["_actorRestrictions"] = actor;
            }
        }
Exemplo n.º 23
0
        public override void UpdateVisualization()
        {
            if (this.mScene.StateView == null)
            {
                return;
            }
            SizeF         size;
            float         w  = 20;
            float         h  = 15;
            Graphics      g  = this.mScene.StateView.CreateGraphics();
            StringBuilder sb = new StringBuilder();

            ActorDefinition ad = this.mAcOpNode.Actor;

            sb.AppendLine("Ac: " + (ad == null ? "" : ad.Name));

            sb.Append("Op: ");
            switch (this.mAcOpNode.Operation)
            {
            case JazzActorOperationNode.ActorOperation.None:
                sb.Append("None");
                break;

            case JazzActorOperationNode.ActorOperation.SetMirror:
                sb.Append(this.mAcOpNode.Operand
                        ? "Set Mirror" : "Unset Mirror");
                break;
            }

            this.mTextString = sb.ToString();
            size             = g.MeasureString(this.mTextString, sTextFont);
            w = Math.Max(w, size.Width + 5);
            h = Math.Max(h, size.Height + 5);

            this.mEntryAnchor.SetPosition(0, h / 2);
            this.mTargetAnchor.SetPosition(w, h / 2);

            if (this.mBorderPath == null)
            {
                this.mBorderPath = new GraphicsPath();
            }
            this.mBorderPath.Reset();
            AddRoundedRectangle(this.mBorderPath, 0, 0, w, h, 5);

            float bbp = 2 * AnchorPoint.Radius;

            this.BoundingBox = new RectangleF(
                -bbp, -bbp, w + 2 * bbp, h + 2 * bbp);
        }
        /// <summary>
        /// Creates the DragAndDrop object's references, and begins the drag operation.
        /// </summary>
        /// <param name="forgelightGame">The forgelight game containing "actor"</param>
        /// <param name="actor">The selected actor</param>
        private void BeginDrag(ForgelightGame forgelightGame, Adr actor)
        {
            ActorDefinition actorDefinition = new ActorDefinition
            {
                forgelightGame  = forgelightGame,
                actorDefinition = actor
            };

            DragAndDrop.objectReferences = new Object[0];
            DragAndDrop.PrepareStartDrag();
            DragAndDrop.SetGenericData("ActorDefinition", actorDefinition);
            DragAndDrop.StartDrag("ActorDrag");

            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
        }
Exemplo n.º 25
0
        private static ActorDefinition CreateWeapon(ActorDefinition inventory)
        {
            int totalFrames = inventory.States.Frames.Count;
            ActorActionFunction lightZeroActionFunc = new ActorActionFunction("A_LIGHT0");

            ActorDefinition weapon = new ActorDefinition("WEAPON", inventory);

            weapon.ActorType.Set(ActorType.Weapon);
            weapon.Properties.InventoryPickupSound  = "MISC/W_PKUP".AsUpper();
            weapon.Properties.WeaponDefaultKickBack = true;
            weapon.States.Labels.Add("LIGHTDONE", totalFrames);
            weapon.States.Frames.Add(new ActorFrame(totalFrames, "SHTGE", 0, MakeProperties(), lightZeroActionFunc, stop, 0));

            return(weapon);
        }
Exemplo n.º 26
0
        private void AddDefinitionButton_Click(object sender, System.EventArgs e)
        {
            ListWindow window = new ListWindow();

            window.PopulateForm(actors.Items);

            if (window.ShowDialog() == DialogResult.OK)
            {
                ActorDefinition definition = actors.CreateActorDefinition((window.chosenObject as ActorEntry));
                TreeNode        node       = new TreeNode(definition.Name);
                node.Name = definition.Hash.ToString();
                node.Tag  = definition;
                definitions.Nodes.Add(node);
            }
        }
Exemplo n.º 27
0
        public override void UpdateVisualization()
        {
            if (this.mScene.StateView == null)
            {
                return;
            }
            SizeF size;
            float w = 40;
            float h = 15;

            Graphics      g  = this.mScene.StateView.CreateGraphics();
            StringBuilder sb = new StringBuilder();

            ActorDefinition ad = this.mStopNode.Actor;

            /*this.mActorString = "Actor: " + (ad == null ? "" : ad.Name);
             * //w = Math.Max(w, kAGW * this.mActorString.Length + 4);
             * size = g.MeasureString(this.mActorString, TextFont);
             * w = Math.Max(w, size.Width + 5);/* */
            sb.AppendLine("Actor: " + (ad == null ? "" : ad.Name));

            /*this.mPropsString = "Flags: "
             + AnimFlagString(this.mStopNode.Flags);
             + //w = Math.Max(w, kAGW * this.mPropsString.Length + 4);
             + size = g.MeasureString(this.mPropsString, TextFont);
             + w = Math.Max(w, size.Width + 5);/* */
            sb.Append("Flags: " + AnimFlagString(this.mStopNode.Flags));

            this.mTextString = sb.ToString();
            size             = g.MeasureString(this.mTextString, sTextFont);
            w = Math.Max(w, size.Width + 5);
            h = Math.Max(h, size.Height + 5);

            this.mEntryAnchor.SetPosition(0, h / 2);
            this.mTargetAnchor.SetPosition(w, h / 2);

            if (this.mBorderPath == null)
            {
                this.mBorderPath = new GraphicsPath();
            }
            this.mBorderPath.Reset();
            AddRoundedRectangle(this.mBorderPath, 0, 0, w, h, 5);

            float bbp = 2 * AnchorPoint.Radius;

            this.BoundingBox = new RectangleF(
                -bbp, -bbp, w + 2 * bbp, h + 2 * bbp);
        }
Exemplo n.º 28
0
 public Entity(int id, ActorDefinition definition, Vec3F position, BitAngle angle,
               Sector sector, EntityManager manager)
 {
     ID             = id;
     Definition     = definition;
     Position       = new Vec3Interpolation(position);
     Angle          = angle;
     Box            = CreateBoxAt(position);
     Sector         = sector;
     entityManager  = manager;
     frameTracker   = new FrameTracker(this);
     GameObject     = CreateGameObject();
     meshComponents = new EntityMeshComponents(this, GameObject);
     collider       = CreateCollider();
     collisionInfo  = CollisionInfo.CreateOn(GameObject, this);
 }
Exemplo n.º 29
0
        private static ActorDefinition CreateBaseSpawnPoint(ActorDefinition actorBase)
        {
            ActorDefinition spawnpoint = new ActorDefinition("SPAWNPOINT", actorBase);

            spawnpoint.ActorType.Set(ActorType.SpawnPoint);
            spawnpoint.Flags.Set(ActorFlagType.DontSplash, true);
            spawnpoint.Flags.Set(ActorFlagType.Invisible, true);
            spawnpoint.Flags.Set(ActorFlagType.NoBlockmap, true);
            spawnpoint.Flags.Set(ActorFlagType.NoGravity, true);

            int totalFrames = spawnpoint.States.Frames.Count;

            spawnpoint.States.Labels.Add("SPAWN", totalFrames);
            spawnpoint.States.Frames.Add(new ActorFrame(totalFrames, "NULLA", -1, MakeProperties(), MakeNoAction(), stop, 0));

            return(spawnpoint);
        }
Exemplo n.º 30
0
        private static ActorDefinition CreateUnknown(ActorDefinition actorBase)
        {
            ActorDefinition unknown = new ActorDefinition("UNKNOWN", actorBase);

            unknown.Properties.Height = 56;
            unknown.Properties.Radius = 32;
            unknown.Flags.Set(ActorFlagType.DontSplash, true);
            unknown.Flags.Set(ActorFlagType.NoBlockmap, true);
            unknown.Flags.Set(ActorFlagType.NoGravity, true);

            int totalFrames = unknown.States.Frames.Count;

            unknown.States.Labels.Add("SPAWN", totalFrames);
            unknown.States.Frames.Add(new ActorFrame(totalFrames, "UNKNA", -1, MakeProperties(), MakeNoAction(), stop, 0));

            return(unknown);
        }
Exemplo n.º 31
0
        public override IEnumerable <ActorDefinition> ParseActors(XElement schemeMedium)
        {
            if (schemeMedium == null)
            {
                throw new ArgumentNullException("schemeMedium");
            }

            var actorsElement = schemeMedium.SingleOrDefault("Actors");

            if (actorsElement == null)
            {
                throw new ArgumentNullException("");
            }

            var actors = new List <ActorDefinition>();

            foreach (var element in actorsElement.Elements().ToList())
            {
                ActorDefinition actor = null;
                if (element.Element("IsIdentity") != null)
                {
                    actor = ActorDefinition.CreateIsIdentity(GetName(element), GetId(element.Element("IsIdentity")));
                }
                else if (element.Element("Rule") != null)
                {
                    actor = ActorDefinition.CreateRule(GetName(element), GetRuleName(element.Element("Rule")));
                    var parameters = element.Element("Rule").Elements("RuleParameter");
                    foreach (var parameter in parameters)
                    {
                        actor.AddParameter(GetName(parameter), GetValue(parameter));
                    }
                }
                else if (element.Element("IsInRole") != null)
                {
                    actor = ActorDefinition.CreateIsInRole(GetName(element), GetId(element.Element("IsInRole")));
                }

                if (actor != null)
                {
                    actors.Add(actor);
                }
            }

            return(actors);
        }
Exemplo n.º 32
0
        private void AddDefinitionButton_Click(object sender, System.EventArgs e)
        {
            ListWindow window = new ListWindow();

            window.PopulateForm(actors.Items);

            if (window.ShowDialog() == DialogResult.OK)
            {
                ActorDefinition definition = actors.CreateActorDefinition((window.chosenObject as ActorEntry));
                TreeNode        node       = new TreeNode(definition.Name);
                node.Name = definition.FrameNameHash.ToString();
                node.Tag  = definition;
                definitions.Nodes.Add(node);

                Text          = Language.GetString("$ACTOR_EDITOR_TITLE") + "*";
                bIsFileEdited = true;
            }
        }
Exemplo n.º 33
0
        private static ActorDefinition CreateBaseDefinition()
        {
            Optional <ActorActionFunction> genericFreezeDeath = new ActorActionFunction("A_GenericFreezeDeath");
            Optional <ActorActionFunction> freezeDeathChunks  = new ActorActionFunction("A_FreezeDeathChunks");

            ActorDefinition actor = new ActorDefinition("ACTOR", Empty);

            actor.States.Labels.Add("SPAWN", 0);
            actor.States.Frames.Add(new ActorFrame(0, "TNT1A", -1, MakeProperties(), MakeNoAction(), stop, 0));
            actor.States.Labels.Add("NULL", 1);
            actor.States.Frames.Add(new ActorFrame(1, "TNT1A", 1, MakeProperties(), MakeNoAction(), stop, 0));
            actor.States.Labels.Add("GENERICFREEZEDEATH", 2);
            actor.States.Frames.Add(new ActorFrame(2, "#####", 5, MakeProperties(), genericFreezeDeath, stop, 1));
            actor.States.Frames.Add(new ActorFrame(3, "----A", 1, MakeProperties(), freezeDeathChunks, wait, 0));
            actor.States.Labels.Add("GENERICCRUSH", 4);
            actor.States.Frames.Add(new ActorFrame(4, "POL5A", -1, MakeProperties(), MakeNoAction(), stop, 0));

            return(actor);
        }
Exemplo n.º 34
0
 public void SetNamespaceMap(string sourceFile, string nameSpace, 
     ActorDefinition actor)
 {
     if (sourceFile == null)
         throw new ArgumentNullException("sourceFile");
     if (nameSpace == null)
         throw new ArgumentNullException("namespaces");
     SortedDictionary<string, ActorDefinition> dict;
     if (!this.mSrcFile2Ns2Actor.TryGetValue(sourceFile, out dict))
     {
         dict = new SortedDictionary<string, ActorDefinition>();
         this.mSrcFile2Ns2Actor.Add(sourceFile, dict);
     }
     dict[nameSpace] = actor;
 }
Exemplo n.º 35
0
 public AnimNamespace(string name, ActorDefinition Actor)
 {
     this.Name = name;
     this.Actor = Actor;
 }
Exemplo n.º 36
0
 public void AddNamespaceSlotSuffix(ActorDefinition targetNamespace,
     ParamDefinition suffixParameter)
 {
     this.mActorSuffixList.Add(
         new ActorSuffix(targetNamespace, suffixParameter));
 }
Exemplo n.º 37
0
 public ActorSuffix(ActorDefinition actor, ParamDefinition param)
 {
     this.Actor = actor;
     this.Param = param;
 }
Exemplo n.º 38
0
        private JazzStateMachine.Animation ExportEntry(
            string sourceFile, uint code, bool useSourceFile,
            string nameSpace, ActorDefinition actor,
            IDictionary<ulong, string> nameMap, bool ean)
        {
            System.IO.Stream s = null;
            uint hash;
            string name;
            JazzStateMachine.Animation animation
                = new JazzStateMachine.Animation(0, null, s);
            if (useSourceFile)
            {
                // TODO: sourceFile should not allow parsable numbers
                // Try to create a better brute force unhasher for
                // reading animation source files.
                if (!sourceFile.StartsWith("0x") ||
                    !uint.TryParse(sourceFile.Substring(2),
                        System.Globalization.NumberStyles.HexNumber,
                        null, out hash))
                {
                    hash = FNVHash.HashString32(sourceFile);
                    if (!nameMap.TryGetValue(hash, out name) &&
                        (ean || !KeyNameReg.TryFindName(hash, out name)))
                    {
                        nameMap[hash] = sourceFile;
                    }
                }
                animation.NameHash = hash;
            }
            else
            {
                animation.NameHash = code;
            }
            if (nameSpace.StartsWith("0x") &&
                uint.TryParse(nameSpace.Substring(2),
                    System.Globalization.NumberStyles.HexNumber,
                    null, out hash))
            {
                animation.Actor1Hash = hash;
            }
            else
            {
                hash = FNVHash.HashString32(nameSpace);
                if (!nameMap.TryGetValue(hash, out name) &&
                    (ean || !KeyNameReg.TryFindName(hash, out name)))
                {
                    nameMap[hash] = sourceFile;
                }
                animation.Actor1Hash = hash;
            }

            animation.Actor2Hash = actor == null ? 0 : actor.NameHash;

            return animation;
        }
Exemplo n.º 39
0
 private JazzStateMachine.Animation ExportEntry(uint code,
     string nameSpace, ActorDefinition actor,
     IDictionary<ulong, string> nameMap, bool exportAllNames)
 {
     return this.ExportEntry(null, code, false,
         nameSpace, actor, nameMap, exportAllNames);
 }
Exemplo n.º 40
0
 public bool RemoveActorDefinition(ActorDefinition actor)
 {
     int index = this.mActorDefinitions.IndexOf(actor);
     if (index < 0)
     {
         return false;
     }
     this.mActorDefinitions.RemoveAt(index);
     return true;
 }
Exemplo n.º 41
0
 public bool AddActorDefinition(ActorDefinition actor)
 {
     if (this.mActorDefinitions.Contains(actor))
     {
         return false;
     }
     this.mActorDefinitions.Add(actor);
     return true;
 }
Exemplo n.º 42
0
        public StateMachine(GenericRCOLResource jazzResource)
            : this("")
        {
            if (jazzResource == null)
            {
                throw new ArgumentNullException("jazzResource");
            }
            GenericRCOLResource.ChunkEntryList chunkEntries
                = jazzResource.ChunkEntries;
            if (chunkEntries == null || chunkEntries.Count == 0)
            {
                throw new ArgumentException(
                    "RCOL Resource is empty", "jazzResource");
            }
            KeyNameReg.RefreshKeyNameMaps();
            uint hash;
            string name;
            int i, j, index = -1;
            State state;
            ActorDefinition ad;
            ParamDefinition pd;
            DecisionGraphNode dgn;
            JazzStateMachine jazzSM = null;
            GenericRCOLResource.ChunkEntry ce;
            AChunkObject[] chunks = new AChunkObject[chunkEntries.Count];
            List<ActorDefinition> actorDefs = new List<ActorDefinition>();
            List<ParamDefinition> paramDefs = new List<ParamDefinition>();

            #region Phase 1: Instantiate Chunks and Copy over value fields
            for (i = 0; i < chunkEntries.Count; i++)
            {
                ce = chunkEntries[i];
                hash = ce.TGIBlock.ResourceType;
                switch (hash)
                {
                    case PlayAnimationNode.ResourceType:
                        JazzPlayAnimationNode jpan
                            = ce.RCOLBlock as JazzPlayAnimationNode;
                        PlayAnimationNode lan = new PlayAnimationNode();
                        lan.ClipKey = new RK(jpan.ClipResource);
                        lan.TrackMaskKey = new RK(jpan.TkmkResource);
                        // lan.SlotSetup copied over later
                        lan.AdditiveClipKey
                            = new RK(jpan.AdditiveClipResource);
                        lan.ClipPattern = jpan.Animation;
                        lan.AdditiveClipPattern = jpan.AdditiveAnimation;
                        lan.Flags = jpan.AnimationNodeFlags;
                        lan.Priority = jpan.AnimationPriority1;
                        lan.BlendInTime = jpan.BlendInTime;
                        lan.BlendOutTime = jpan.BlendOutTime;
                        lan.Speed = jpan.Speed;
                        // lan.Actor set later
                        lan.TimingPriority = jpan.TimingPriority;
                        chunks[i] = lan;
                        break;
                    case StopAnimationNode.ResourceType:
                        JazzStopAnimationNode jsan
                            = ce.RCOLBlock as JazzStopAnimationNode;
                        StopAnimationNode san = new StopAnimationNode();
                        san.Flags = jsan.AnimationFlags;
                        san.Priority = jsan.AnimationPriority1;
                        san.BlendInTime = jsan.BlendInTime;
                        san.BlendOutTime = jsan.BlendOutTime;
                        san.Speed = jsan.Speed;
                        // san.Actor set later
                        san.TimingPriority = jsan.TimingPriority;
                        chunks[i] = san;
                        break;
                    case ActorOperationNode.ResourceType:
                        JazzActorOperationNode jaon
                            = ce.RCOLBlock as JazzActorOperationNode;
                        ActorOperationNode aon
                            = new ActorOperationNode(jaon.ActorOp);
                        // aon.Target set later
                        aon.Operand = jaon.Operand != 0;
                        chunks[i] = aon;
                        break;
                    case CreatePropNode.ResourceType:
                        JazzCreatePropNode jcpn
                            = ce.RCOLBlock as JazzCreatePropNode;
                        CreatePropNode cpn = new CreatePropNode();
                        // cpn.PropActor set later
                        // cpn.PropParameter set later
                        cpn.PropKey = new RK(jcpn.PropResource);
                        chunks[i] = cpn;
                        break;
                    case RandomNode.ResourceType:
                        JazzRandomNode jrand
                            = ce.RCOLBlock as JazzRandomNode;
                        RandomNode rand = new RandomNode();
                        // rand.Slices set later
                        rand.Flags = jrand.Properties;
                        chunks[i] = rand;
                        break;
                    case SelectOnParameterNode.ResourceType:
                        // sopn.Parameter set later
                        // sopn.Cases set later
                        chunks[i] = new SelectOnParameterNode();
                        break;
                    case SelectOnDestinationNode.ResourceType:
                        // sodn.Cases set later
                        chunks[i] = new SelectOnDestinationNode();
                        break;
                    case NextStateNode.ResourceType:
                        // nsn.NextState set later
                        chunks[i] = new NextStateNode();
                        break;
                    case DecisionGraph.ResourceType:
                        // dg.State set later
                        // dg.DecisionMakers set later
                        // dg.EntryPoints set later
                        chunks[i] = new DecisionGraph();
                        break;
                    case State.ResourceType:
                        JazzState js = ce.RCOLBlock as JazzState;
                        hash = js.NameHash;
                        if (!KeyNameReg.TryFindName(hash, out name))
                            name = KeyNameReg.UnhashName(hash);
                        state = new State(name);
                        state.Flags = js.Properties;
                        // state.DecisionGraph set later
                        // state.Transitions set later
                        state.AwarenessOverlayLevel
                            = js.AwarenessOverlayLevel;
                        chunks[i] = state;
                        break;
                    case ParamDefinition.ResourceType:
                        JazzParameterDefinition jpd
                            = ce.RCOLBlock as JazzParameterDefinition;
                        hash = jpd.NameHash;
                        if (!KeyNameReg.TryFindName(hash, out name))
                            name = KeyNameReg.UnhashName(hash);
                        pd = new ParamDefinition(name);

                        hash = jpd.DefaultValue;
                        if (!KeyNameReg.TryFindName(hash, out name))
                            name = KeyNameReg.UnhashName(hash);
                        pd.DefaultValue = name;
                        chunks[i] = pd;
                        paramDefs.Add(pd);
                        break;
                    case ActorDefinition.ResourceType:
                        JazzActorDefinition jad
                            = ce.RCOLBlock as JazzActorDefinition;
                        hash = jad.NameHash;
                        if (!KeyNameReg.TryFindName(hash, out name))
                            name = KeyNameReg.UnhashName(hash);
                        ad = new ActorDefinition(name);
                        chunks[i] = ad;
                        actorDefs.Add(ad);
                        break;
                    case StateMachine.ResourceType:
                        if (index != -1)
                        {
                            throw new Exception(
                                "More than one State Machine in RCOL");
                        }
                        index = i;
                        jazzSM = ce.RCOLBlock as JazzStateMachine;
                        hash = jazzSM.NameHash;
                        if (hash == 0)
                        {
                            name = null;
                            this.bNameIsHash = true;
                        }
                        else if (!KeyNameReg.TryFindName(hash, out name))
                        {
                            name = KeyNameReg.UnhashName(hash);
                            this.bNameIsHash = true;
                        }
                        else
                        {
                            this.bNameIsHash = false;
                        }
                        this.mName = name;
                        this.mNameHash = hash;
                        // this.mActorDefinitions set later
                        // this.mParameterDefinitions set later
                        // this.mStates set later
                        this.mFlags = jazzSM.Properties;
                        this.mDefaultPriority = jazzSM.AutomationPriority;
                        this.mAwarenessOverlayLevel
                            = jazzSM.AwarenessOverlayLevel;
                        chunks[i] = this;
                        break;
                }
            }
            if (index == -1)
            {
                throw new Exception("RCOL does not contain a Jazz Graph");
            }
            #endregion

            #region Phase 2: Copy over fields referencing other chunks
            for (i = 0; i < chunkEntries.Count; i++)
            {
                ce = chunkEntries[i];
                switch (ce.TGIBlock.ResourceType)
                {
                    case PlayAnimationNode.ResourceType:
                        JazzPlayAnimationNode jpan
                            = ce.RCOLBlock as JazzPlayAnimationNode;
                        PlayAnimationNode lan
                            = chunks[i] as PlayAnimationNode;
                        index = jpan.ActorDefinitionIndex.TGIBlockIndex;
                        lan.Actor = index < 0
                            ? null : chunks[index + 1] as ActorDefinition;
                        break;
                    case StopAnimationNode.ResourceType:
                        JazzStopAnimationNode jsan
                            = ce.RCOLBlock as JazzStopAnimationNode;
                        StopAnimationNode san
                            = chunks[i] as StopAnimationNode;
                        index = jsan.ActorDefinitionIndex.TGIBlockIndex;
                        san.Actor = index < 0
                            ? null : chunks[index + 1] as ActorDefinition;
                        break;
                    case ActorOperationNode.ResourceType:
                        JazzActorOperationNode jaon
                            = ce.RCOLBlock as JazzActorOperationNode;
                        ActorOperationNode aon
                            = chunks[i] as ActorOperationNode;
                        index = jaon.ActorDefinitionIndex.TGIBlockIndex;
                        aon.Actor = index < 0
                            ? null : chunks[index + 1] as ActorDefinition;
                        break;
                    case CreatePropNode.ResourceType:
                        JazzCreatePropNode jcpn
                            = ce.RCOLBlock as JazzCreatePropNode;
                        CreatePropNode cpn = chunks[i] as CreatePropNode;
                        index = jcpn.ActorDefinitionIndex.TGIBlockIndex;
                        cpn.PropActor = index < 0
                            ? null : chunks[index + 1] as ActorDefinition;
                        index = jcpn.ParameterDefinitionIndex.TGIBlockIndex;
                        cpn.PropParam = index < 0
                            ? null : chunks[index + 1] as ParamDefinition;
                        break;
                    case RandomNode.ResourceType:
                        JazzRandomNode jrand = ce.RCOLBlock as JazzRandomNode;
                        RandomNode rand = chunks[i] as RandomNode;
                        RandomNode.Slice slice;
                        List<RandomNode.Slice> slices = rand.Slices;
                        foreach (JazzRandomNode.Outcome oc in jrand.Outcomes)
                        {
                            slice = new RandomNode.Slice(oc.Weight);
                            foreach (GenericRCOLResource.ChunkReference cr
                                in oc.DecisionGraphIndexes)
                            {
                                index = cr.TGIBlockIndex;
                                dgn = index < 0 ? null
                                    : chunks[index + 1] as DecisionGraphNode;
                                slice.Targets.Add(dgn);
                            }
                            slices.Add(slice);
                        }
                        break;
                    case SelectOnParameterNode.ResourceType:
                        JazzSelectOnParameterNode jsopn
                            = ce.RCOLBlock as JazzSelectOnParameterNode;
                        SelectOnParameterNode sopn
                            = chunks[i] as SelectOnParameterNode;
                        index = jsopn.ParameterDefinitionIndex.TGIBlockIndex;
                        sopn.Parameter = index < 0 ? null
                            : chunks[index + 1] as ParamDefinition;
                        foreach (JazzSelectOnParameterNode.Match mp
                            in jsopn.Matches)
                        {
                            hash = mp.TestValue;
                            if (!KeyNameReg.TryFindName(hash, out name))
                                name = KeyNameReg.UnhashName(hash);
                            foreach (GenericRCOLResource.ChunkReference cr
                                in mp.DecisionGraphIndexes)
                            {
                                index = cr.TGIBlockIndex;
                                dgn = index < 0 ? null
                                    : chunks[index + 1] as DecisionGraphNode;
                                sopn.AddCaseTarget(name, dgn);
                            }
                        }
                        break;
                    case SelectOnDestinationNode.ResourceType:
                        JazzSelectOnDestinationNode jsodn
                            = ce.RCOLBlock as JazzSelectOnDestinationNode;
                        SelectOnDestinationNode sodn
                            = chunks[i] as SelectOnDestinationNode;
                        foreach (JazzSelectOnDestinationNode.Match md
                            in jsodn.Matches)
                        {
                            index = md.StateIndex.TGIBlockIndex;
                            state = index < 0 ? null
                                : chunks[index + 1] as State;
                            foreach (GenericRCOLResource.ChunkReference cr
                                in md.DecisionGraphIndexes)
                            {
                                index = cr.TGIBlockIndex;
                                dgn = index < 0 ? null
                                    : chunks[index + 1] as DecisionGraphNode;
                                sodn.AddCaseTarget(state, dgn);
                            }
                        }
                        break;
                    case NextStateNode.ResourceType:
                        JazzNextStateNode jnsn
                            = ce.RCOLBlock as JazzNextStateNode;
                        NextStateNode nsn = chunks[i] as NextStateNode;
                        index = jnsn.StateIndex.TGIBlockIndex;
                        nsn.NextState = index < 0 ? null
                            : chunks[index + 1] as State;
                        break;
                    case DecisionGraph.ResourceType:
                        JazzDecisionGraph jdg
                            = ce.RCOLBlock as JazzDecisionGraph;
                        DecisionGraph dg = chunks[i] as DecisionGraph;
                        foreach (GenericRCOLResource.ChunkReference dm
                            in jdg.OutboundDecisionGraphIndexes)
                        {
                            index = dm.TGIBlockIndex;
                            dgn = index < 0 ? null
                                : chunks[index + 1] as DecisionGraphNode;
                            dg.AddDecisionMaker(dgn);
                        }
                        foreach (GenericRCOLResource.ChunkReference ep
                            in jdg.InboundDecisionGraphIndexes)
                        {
                            index = ep.TGIBlockIndex;
                            dgn = index < 0 ? null
                                : chunks[index + 1] as DecisionGraphNode;
                            dg.AddEntryPoint(dgn);
                        }
                        break;
                    case State.ResourceType:
                        State transition;
                        JazzState js = ce.RCOLBlock as JazzState;
                        state = chunks[i] as State;
                        index = js.DecisionGraphIndex.TGIBlockIndex;
                        state.DecisionGraph = index < 0 ? null
                            : chunks[index + 1] as DecisionGraph;
                        foreach (GenericRCOLResource.ChunkReference trans
                            in js.OutboundStateIndexes)
                        {
                            index = trans.TGIBlockIndex;
                            transition = index < 0 ? null
                                : chunks[index + 1] as State;
                            state.AddTransition(transition);
                        }
                        break;
                    case ParamDefinition.ResourceType:
                    case ActorDefinition.ResourceType:
                        break;
                    case StateMachine.ResourceType:
                        jazzSM = ce.RCOLBlock as JazzStateMachine;
                        foreach (GenericRCOLResource.ChunkReference jad
                            in jazzSM.ActorDefinitionIndexes)
                        {
                            index = jad.TGIBlockIndex;
                            ad = index < 0 ? null
                                : chunks[index + 1] as ActorDefinition;
                            this.AddActorDefinition(ad);
                        }
                        foreach (GenericRCOLResource.ChunkReference jpd
                            in jazzSM.PropertyDefinitionIndexes)
                        {
                            index = jpd.TGIBlockIndex;
                            pd = index < 0 ? null
                                : chunks[index + 1] as ParamDefinition;
                            this.AddParamDefinition(pd);
                        }
                        foreach (GenericRCOLResource.ChunkReference jst
                            in jazzSM.StateIndexes)
                        {
                            index = jst.TGIBlockIndex;
                            state = index < 0  ? null
                                : chunks[index + 1] as State;
                            this.AddState(state);
                        }
                        break;
                }
            }
            #endregion

            #region Phase 3: Copy over animation slots and Find "Extras"
            for (i = 0; i < chunkEntries.Count; i++)
            {
                ce = chunkEntries[i];
                switch (ce.TGIBlock.ResourceType)
                {
                    case PlayAnimationNode.ResourceType:
                        JazzPlayAnimationNode jpan
                            = ce.RCOLBlock as JazzPlayAnimationNode;
                        PlayAnimationNode lan
                            = chunks[i] as PlayAnimationNode;
                        SlotSetupBuilder ssb = lan.SlotSetup;
                        foreach (JazzPlayAnimationNode.ActorSlot slot
                            in jpan.ActorSlots)
                        {
                            ssb.AddSlotAssignment(slot.ChainId, slot.SlotId,
                                slot.ActorNameHash, slot.SlotNameHash);
                        }
                        foreach (JazzPlayAnimationNode.ActorSuffix suffix
                            in jpan.ActorSuffixes)
                        {
                            hash = suffix.ActorNameHash;
                            ad = null;
                            if (hash != 0)
                            {
                                index = -1;
                                for (i = actorDefs.Count - 1;
                                     i >= 0 && index == -1; i--)
                                {
                                    ad = actorDefs[i];
                                    if (ad.NameHash == hash)
                                    {
                                        index = i;
                                    }
                                }
                                if (index < 0)
                                {
                                    if (!KeyNameReg.TryFindName(hash, out name))
                                        name = KeyNameReg.UnhashName(hash);
                                    ad = new ActorDefinition(name);
                                    actorDefs.Add(ad);
                                    this.mExtraActors.Add(ad);
                                }
                            }
                            hash = suffix.SuffixHash;
                            pd = null;
                            if (hash != 0)
                            {
                                index = -1;
                                for (i = paramDefs.Count - 1;
                                     i >= 0 && index == -1; i--)
                                {
                                    pd = paramDefs[i];
                                    if (pd.NameHash == hash)
                                    {
                                        index = i;
                                    }
                                }
                                if (index < 0)
                                {
                                    if (!KeyNameReg.TryFindName(hash, out name))
                                        name = KeyNameReg.UnhashName(hash);
                                    pd = new ParamDefinition(name);
                                    paramDefs.Add(pd);
                                    this.mExtraParams.Add(pd);
                                }
                            }
                            ssb.AddNamespaceSlotSuffix(ad, pd);
                        }
                        break;
                    case State.ResourceType:
                        state = chunks[i] as State;
                        index = this.mStates.IndexOf(state);
                        if (index < 0)
                        {
                            this.mExtraStates.Add(state);
                        }
                        break;
                    case ParamDefinition.ResourceType:
                        pd = chunks[i] as ParamDefinition;
                        index = this.mParamDefinitions.IndexOf(pd);
                        if (index < 0)
                        {
                            this.mExtraParams.Add(pd);
                        }
                        break;
                    case ActorDefinition.ResourceType:
                        ad = chunks[i] as ActorDefinition;
                        index = this.mActorDefinitions.IndexOf(ad);
                        if (index < 0)
                        {
                            this.mExtraActors.Add(ad);
                        }
                        break;
                }
            }
            #endregion

            #region Phase 4: Copy over Animation CLIP Namespace Map
            RK rk;
            List<RK> rks = this.SlurpReferencedRKs();
            List<uint> foldedClipInstances = new List<uint>(rks.Count);
            for (i = rks.Count - 1; i >= 0; i--)
            {
                rk = rks[i];
                if (rk.TID == 0x6b20c4f3)
                {
                    hash = (uint)((rk.IID >> 0x20) ^ (rk.IID & 0xffffffff));
                    foldedClipInstances.Add(hash);
                }
                else
                {
                    rks.RemoveAt(i);
                }
            }
            index = 0;
            Anim animation;
            Anim[] animations = new Anim[jazzSM.Animations.Count];
            foreach (JazzStateMachine.Animation anim in jazzSM.Animations)
            {
                hash = anim.NameHash;
                if (!foldedClipInstances.Contains(hash))
                {
                    animation = new Anim();
                    animation.SrcFileHash = hash;
                    if (KeyNameReg.TryFindName(hash, out name))
                    {
                        animation.SrcFileName = name;
                        animation.SrcFileIsValid = true;
                    }
                    else
                    {
                        animation.SrcFileName
                            = KeyNameReg.UnhashName(hash);
                        animation.SrcFileIsValid = false;
                    }
                    hash = anim.Actor1Hash;
                    if (KeyNameReg.TryFindName(hash, out name))
                    {
                        animation.Namespace = name;
                    }
                    else
                    {
                        animation.Namespace
                            = string.Concat("0x", hash.ToString("X8"));
                    }
                    hash = anim.Actor2Hash;
                    ad = null;
                    if (hash != 0)
                    {
                        j = -1;
                        for (i = actorDefs.Count - 1; i >= 0 && j < 0; i--)
                        {
                            ad = actorDefs[i];
                            if (ad.NameHash == hash)
                            {
                                j = i;
                            }
                        }
                        if (j < 0)
                        {
                            if (!KeyNameReg.TryFindName(hash, out name))
                                name = KeyNameReg.UnhashName(hash);
                            ad = new ActorDefinition(name);
                            actorDefs.Add(ad);
                            this.mExtraActors.Add(ad);
                        }
                    }
                    animation.Actor = ad;
                    animations[index++] = animation;
                }
            }
            ulong clipHash;
            Dictionary<ulong, string> keyNameMap
                = new Dictionary<ulong, string>();
            for (i = index - 1; i >= 0; i--)
            {
                animation = animations[i];
                this.mNamespaceMap.SetNamespaceMap(
                    animation.SrcFileName,
                    animation.Namespace,
                    animation.Actor);
                if (animation.SrcFileIsValid)
                {
                    clipHash = FNVHash.HashString64(animation.SrcFileName);
                    keyNameMap[clipHash] = animation.SrcFileName;
                }
            }
            // Update the Key to Filename Map of the Namespace Map
            SortedDictionary<RK, string> k2fn
                = this.mNamespaceMap.KeyToFilenameMap;
            k2fn.Clear();
            for (i = rks.Count - 1; i >= 0; i--)
            {
                rk = rks[i];
                if (keyNameMap.TryGetValue(rk.IID, out name) ||
                    KeyNameReg.TryFindName(rk.IID, out name))
                {
                    k2fn[rk] = name;
                }
            }
            #endregion
        }
Exemplo n.º 43
0
 private JazzStateMachine.Animation ExportEntry(string sourceFile,
     string nameSpace, ActorDefinition actor,
     IDictionary<ulong, string> nameMap, bool exportAllNames)
 {
     return this.ExportEntry(sourceFile, 0, true,
         nameSpace, actor, nameMap, exportAllNames);
 }