Ejemplo n.º 1
0
        public static Savegame ReadNew(BinaryReader r)
        {
            Savegame sg = new Savegame();

            sg.version       = ZZVersion.ReadNew(r);
            sg.name          = r.ReadZString();
            sg.secondsPlayed = r.ReadInt32();
            sg.progress      = r.ReadInt32();
            if (r.ReadUInt32() != LocationBlockSize)
            {
                throw new InvalidDataException("Invalid size of savegame location block");
            }
            sg.sceneId = r.ReadInt32();
            sg.entryId = r.ReadInt32();

            var sceneCount = r.ReadUInt32();

            sg.gameState.EnsureCapacity((int)sceneCount);
            for (uint i = 0; i < sceneCount; i++)
            {
                var sceneName = r.ReadZString();
                var modCount  = r.ReadInt32();
                var mods      = new List <IGameStateMod>(modCount);
                for (int j = 0; j < modCount; j++)
                {
                    mods.Add(IGameStateMod.ReadNew(r));
                }
                sg.gameState[sceneName] = mods;
            }

            var itemCount = r.ReadUInt32();

            sg.inventory.EnsureCapacity((int)itemCount);
            for (uint i = 0; i < itemCount; i++)
            {
                sg.inventory.Add(InventoryCard.ReadNew(r));
            }

            sg.pixiesHolding = r.ReadUInt32();
            sg.pixiesCatched = r.ReadUInt32();

            if (r.ReadInt32() != GlobalVar.Count)
            {
                throw new InvalidDataException("Invalid global variable count");
            }
            for (int i = 0; i < sg.globalVars.Length; i++)
            {
                sg.globalVars[i] = GlobalVar.ReadNew(r);
            }

            sg.switchGameMinMoves = r.ReadUInt32();
            return(sg);
        }
Ejemplo n.º 2
0
 public DialogScript(ITagContainer diContainer) : base(diContainer, CreateEntityContainer)
 {
     World.SetMaxCapacity <components.DialogState>(1);
     db       = diContainer.GetTag <MappedDB>();
     ui       = diContainer.GetTag <UI>();
     scene    = diContainer.GetTag <Scene>();
     game     = diContainer.GetTag <Game>();
     savegame = diContainer.GetTag <zzio.Savegame>();
     recorder = diContainer.GetTag <EntityCommandRecorder>();
     startDialogDisposable = World.Subscribe <messages.StartDialog>(HandleStartDialog);
     removedDisposable     = World.SubscribeComponentRemoved <components.DialogState>(HandleDialogStateRemoved);
 }
Ejemplo n.º 3
0
 public Savegame(ITagContainer diContainer)
 {
     world    = diContainer.GetTag <DefaultEcs.World>();
     scene    = diContainer.GetTag <Scene>();
     savegame = diContainer.GetTag <zzio.Savegame>();
     disableAttackTriggerDisposable = world.Subscribe <GSModDisableAttackTrigger>(HandleDisableAttackTrigger);
     removeItemDisposable           = world.Subscribe <GSModRemoveItem>(HandleRemoveItem);
     changeNpcStateDisposable       = world.Subscribe <GSModChangeNPCState>(HandleChangeNpcState);
     disableTriggerDisposable       = world.Subscribe <GSModDisableTrigger>(HandleDisableTrigger);
     removeModelDisposable          = world.Subscribe <GSModRemoveModel>(HandleRemoveModel);
     setTriggerDisposable           = world.Subscribe <GSModSetTrigger>(HandleSetTrigger);
     setNpcModifierDisposable       = world.Subscribe <GSModSetNPCModifier>(HandleSetNpcModifier);
     gsmodForSceneDisposable        = world.Subscribe <messages.GSModForScene>(HandleGSModForScene);
 }