Ejemplo n.º 1
0
    public SerializedPersistentObject GetPersistentObject(string id)
    {
        SerializedPersistentObject o = null;

        persistentObjects.TryGetValue(id, out o);
        return(o);
    }
Ejemplo n.º 2
0
    override public void Start()
    {
        persistentProperties = new Hashtable();
        SerializedPersistentObject o = LoadObjectState();

        ConstructFromSerialized(o);
    }
Ejemplo n.º 3
0
 public static void SavePersistentObject(SerializedPersistentObject o)
 {
     if (save == null)
     {
         return;
     }
     save.SavePersistentObject(o);
 }
Ejemplo n.º 4
0
 virtual public void ConstructFromSerialized(SerializedPersistentObject s)
 {
     if (s == null)
     {
         return;
     }
     this.persistentProperties = s.persistentProperties;
 }
Ejemplo n.º 5
0
 override public void ConstructFromSerialized(SerializedPersistentObject s)
 {
     if (s == null)
     {
         return;
     }
     this.persistentProperties = s.persistentProperties;
     acceptedItemBefore        = (bool)this.persistentProperties["Accepted"];
 }
Ejemplo n.º 6
0
 public static void SavePersistentObject(SerializedPersistentObject o)
 {
     if (save == null)
     {
         Debug.LogWarning("Save file is null!");
         return;
     }
     save.SavePersistentObject(o);
 }
Ejemplo n.º 7
0
 public override void ConstructFromSerialized(SerializedPersistentObject s)
 {
     if (s == null)
     {
         return;
     }
     persistentProperties = s.persistentProperties;
     time = 0;
     if (persistentProperties.ContainsKey(nameof(time)))
     {
         time = (float)persistentProperties[nameof(time)];
     }
 }
Ejemplo n.º 8
0
    void OnEnable()
    {
        SerializedPersistentObject o = LoadObjectState();

        if (o != null)
        {
            if (!((bool)o.persistentProperties["enabled"]))
            {
                Disable();
                return;
            }
        }
        UpdateState(true);
    }
Ejemplo n.º 9
0
    void Load()
    {
        SerializedPersistentObject savedState = LoadObjectState();

        if (savedState != null)
        {
            DecodeAndUpdateMap((bool[])savedState.persistentProperties[MAP_PROPERTY]);
        }
        else
        {
            WipeMap();
        }

        StartUpdatingMap();
    }
Ejemplo n.º 10
0
    public override void Start()
    {
        //load, check the dialogue hash, if it's the same then go to the last line
        persistentProperties = new Hashtable();
        npc = GetComponent <NPC>();
        SerializedPersistentObject o = LoadObjectState();

        // this isn't a race condition with changing NPC dialogue on game flags, because that happens before Start()
        if (o != null && npc.GetConversationsHash() == (int)o.persistentProperties["dialogueHash"])
        {
            ConstructFromSerialized(o);
            npc.currentConversation = (int)persistentProperties["currentConversation"];
            npc.currentDialogueLine = (int)persistentProperties["currentDialogueLine"];
        }
    }
Ejemplo n.º 11
0
    override public void ConstructFromSerialized(SerializedPersistentObject s)
    {
        if (s == null)
        {
            this.baseInventory.AddAll(startingInventory);
            return;
        }

        this.persistentProperties = s.persistentProperties;

        this.gameFlagsHit = ((List <int>)s.persistentProperties["GameFlags"]).Select(
            x => (GameFlag)x
            ).ToList();

        this.baseInventory = s.persistentProperties["Inventory"] as InventoryList;
    }
Ejemplo n.º 12
0
    void OnEnable()
    {
        if (firstEnable)
        {
            firstEnable = false;

            SerializedPersistentObject o = LoadObjectState();
            if (o != null)
            {
                bool wasEnabled = (bool)o.persistentProperties["enabled"];
                if (!wasEnabled)
                {
                    Disable();
                }
            }
        }
        else
        {
            UpdateState(true);
        }
    }
Ejemplo n.º 13
0
    override public void ConstructFromSerialized(SerializedPersistentObject s)
    {
        this.baseInventory = new InventoryList();
        if (s == null)
        {
            this.baseInventory.AddAll(startingInventory.Select(
                                          x => x.GetItem()
                                          ).ToList());
            return;
        }

        this.persistentProperties = s.persistentProperties;

        this.gameFlagsHit = ((List <int>)s.persistentProperties["GameFlags"]).Select(
            x => (GameFlag)x
            ).ToList();

        this.baseInventory.LoadFromSerializableInventoryList(
            (SerializableInventoryList)s.persistentProperties["Inventory"]
            );
    }
Ejemplo n.º 14
0
    void OnSceneLoad(Scene scene, LoadSceneMode mode)
    {
        if (!string.IsNullOrEmpty(currentScene))
        {
            SaveCurrentMap();
        }

        currentScene = scene.name;

        SerializedPersistentObject savedState = LoadObjectState();

        if (savedState != null)
        {
            DecodeAndUpdateMap((bool[])savedState.persistentProperties[mapProp]);
        }
        else
        {
            WipeMap();
        }

        StartUpdatingMap();
    }
Ejemplo n.º 15
0
 public void SavePersistentObject(SerializedPersistentObject o)
 {
     persistentObjects[o.id] = o;
 }
Ejemplo n.º 16
0
    // this is called after the global Awake so the initial save data will always be present
    virtual public void Start()
    {
        SerializedPersistentObject o = LoadObjectState();

        ConstructFromSerialized(o);
    }