Ejemplo n.º 1
0
    public void Reset()
    {
        PersistantPlayer playerInfo = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).persistance.GetPlayerInfo(this.baseEntity.userID);

        playerInfo.unlockedItems = (__Null) new List <int>();
        ((ServerMgr)SingletonComponent <ServerMgr> .Instance).persistance.SetPlayerInfo(this.baseEntity.userID, playerInfo);
        this.baseEntity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
    }
Ejemplo n.º 2
0
    public bool IsUnlocked(ItemDefinition itemDef)
    {
        PersistantPlayer playerInfo = SingletonComponent <ServerMgr> .Instance.persistance.GetPlayerInfo(base.baseEntity.userID);

        if (playerInfo.unlockedItems == null)
        {
            return(false);
        }
        return(playerInfo.unlockedItems.Contains(itemDef.itemid));
    }
Ejemplo n.º 3
0
    public bool IsUnlocked(ItemDefinition itemDef)
    {
        PersistantPlayer playerInfo = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).persistance.GetPlayerInfo(this.baseEntity.userID);

        if (playerInfo.unlockedItems != null)
        {
            return(((List <int>)playerInfo.unlockedItems).Contains(itemDef.itemid));
        }
        return(false);
    }
Ejemplo n.º 4
0
    public void RPC_BeginExperiment(BaseEntity.RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (Object.op_Equality((Object)player, (Object)null) || this.IsWorking())
        {
            return;
        }
        PersistantPlayer playerInfo = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).persistance.GetPlayerInfo(player.userID);
        int num = Random.Range(0, this.experimentalItems.subSpawn.Length);

        for (int index1 = 0; index1 < this.experimentalItems.subSpawn.Length; ++index1)
        {
            int index2 = index1 + num;
            if (index2 >= this.experimentalItems.subSpawn.Length)
            {
                index2 -= this.experimentalItems.subSpawn.Length;
            }
            ItemDefinition itemDef = this.experimentalItems.subSpawn[index2].category.items[0].itemDef;
            if (Object.op_Implicit((Object)itemDef.Blueprint) && !itemDef.Blueprint.defaultBlueprint && (itemDef.Blueprint.userCraftable && itemDef.Blueprint.isResearchable) && (!itemDef.Blueprint.NeedsSteamItem && !((List <int>)playerInfo.unlockedItems).Contains(itemDef.itemid)))
            {
                this.pendingBlueprint = itemDef;
                break;
            }
        }
        if (Object.op_Equality((Object)this.pendingBlueprint, (Object)null))
        {
            player.ChatMessage("You have already unlocked everything for this workbench tier.");
        }
        else
        {
            if (Interface.CallHook("CanExperiment", (object)player, (object)this) != null)
            {
                return;
            }
            Item slot = this.inventory.GetSlot(0);
            if (slot != null)
            {
                if (!slot.MoveToContainer(player.inventory.containerMain, -1, true))
                {
                    slot.Drop(this.GetDropPosition(), this.GetDropVelocity(), (Quaternion)null);
                }
                player.inventory.loot.SendImmediate();
            }
            if (this.experimentStartEffect.isValid)
            {
                Effect.server.Run(this.experimentStartEffect.resourcePath, (BaseEntity)this, 0U, Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false);
            }
            this.SetFlag(BaseEntity.Flags.On, true, false, true);
            this.inventory.SetLocked(true);
            this.CancelInvoke(new Action(this.ExperimentComplete));
            this.Invoke(new Action(this.ExperimentComplete), 5f);
            this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
        }
    }
Ejemplo n.º 5
0
    public PersistantPlayer GetPlayerInfo(ulong playerID)
    {
        PersistantPlayer persistantPlayer = this.FetchFromDatabase(playerID) ?? new PersistantPlayer();

        persistantPlayer.ShouldPool = (__Null)0;
        if (persistantPlayer.unlockedItems == null)
        {
            persistantPlayer.unlockedItems = (__Null) new List <int>();
        }
        return(persistantPlayer);
    }
Ejemplo n.º 6
0
    public PersistantPlayer GetPlayerInfo(ulong playerID)
    {
        PersistantPlayer nums = this.FetchFromDatabase(playerID) ?? new PersistantPlayer();

        nums.ShouldPool = false;
        if (nums.unlockedItems == null)
        {
            nums.unlockedItems = new List <int>();
        }
        return(nums);
    }
Ejemplo n.º 7
0
 public void SetPlayerInfo(ulong playerID, PersistantPlayer info)
 {
     byte[] protoBytes;
     using (TimeWarning timeWarning = TimeWarning.New("SetPlayerInfo", 0.1f))
     {
         using (TimeWarning timeWarning1 = TimeWarning.New("ToProtoBytes", 0.1f))
         {
             protoBytes = info.ToProtoBytes();
         }
         UserPersistance.blueprints.Execute("INSERT OR REPLACE INTO data ( userid, info, updated ) VALUES ( ?, ?, ? )", new object[] { playerID.ToString(), protoBytes, Epoch.Current });
     }
 }
Ejemplo n.º 8
0
    public void Unlock(ItemDefinition itemDef)
    {
        PersistantPlayer playerInfo = SingletonComponent <ServerMgr> .Instance.persistance.GetPlayerInfo(base.baseEntity.userID);

        if (!playerInfo.unlockedItems.Contains(itemDef.itemid))
        {
            playerInfo.unlockedItems.Add(itemDef.itemid);
            SingletonComponent <ServerMgr> .Instance.persistance.SetPlayerInfo(base.baseEntity.userID, playerInfo);

            base.baseEntity.SendNetworkUpdateImmediate(false);
            base.baseEntity.ClientRPCPlayer <int>(null, base.baseEntity, "UnlockedBlueprint", itemDef.itemid);
            base.baseEntity.stats.Add("blueprint_studied", 1, Stats.Steam);
        }
    }
Ejemplo n.º 9
0
    public void Unlock(ItemDefinition itemDef)
    {
        PersistantPlayer playerInfo = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).persistance.GetPlayerInfo(this.baseEntity.userID);

        if (((List <int>)playerInfo.unlockedItems).Contains(itemDef.itemid))
        {
            return;
        }
        ((List <int>)playerInfo.unlockedItems).Add(itemDef.itemid);
        ((ServerMgr)SingletonComponent <ServerMgr> .Instance).persistance.SetPlayerInfo(this.baseEntity.userID, playerInfo);
        this.baseEntity.SendNetworkUpdateImmediate(false);
        this.baseEntity.ClientRPCPlayer <int>((Connection)null, this.baseEntity, "UnlockedBlueprint", itemDef.itemid);
        this.baseEntity.stats.Add("blueprint_studied", 1, Stats.Steam);
    }
Ejemplo n.º 10
0
 public void SetPlayerInfo(ulong playerID, PersistantPlayer info)
 {
     using (TimeWarning.New(nameof(SetPlayerInfo), 0.1f))
     {
         byte[] protoBytes;
         using (TimeWarning.New("ToProtoBytes", 0.1f))
             protoBytes = info.ToProtoBytes();
         UserPersistance.blueprints.Execute("INSERT OR REPLACE INTO data ( userid, info, updated ) VALUES ( ?, ?, ? )", new object[3]
         {
             (object)playerID.ToString(),
             (object)protoBytes,
             (object)Epoch.get_Current()
         });
     }
 }
Ejemplo n.º 11
0
 private void Awake()
 {
     if (StaticInstance == null)
     {
         StaticInstance = this;
         DontDestroyOnLoad(this.gameObject);
         playerRB          = GetComponent <Rigidbody>();
         source            = GetComponent <CinemachineImpulseSource>();
         playerAttackInput = GetComponent <AttackInput>();
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 12
0
 private PersistantPlayer FetchFromDatabase(ulong playerID)
 {
     try
     {
         Row row = UserPersistance.blueprints.QueryRow("SELECT info FROM data WHERE userid = ?", new object[] { playerID.ToString() });
         if (row != null)
         {
             return(PersistantPlayer.Deserialize(row.GetBlob("info")));
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         Debug.LogError(string.Concat("Error loading player blueprints: (", exception.Message, ")"));
     }
     return(null);
 }
Ejemplo n.º 13
0
 public void UnlockAll()
 {
     foreach (ItemBlueprint bp in ItemManager.bpList)
     {
         if (bp.userCraftable && !bp.defaultBlueprint)
         {
             PersistantPlayer playerInfo = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).persistance.GetPlayerInfo(this.baseEntity.userID);
             if (!((List <int>)playerInfo.unlockedItems).Contains(bp.targetItem.itemid))
             {
                 ((List <int>)playerInfo.unlockedItems).Add(bp.targetItem.itemid);
                 ((ServerMgr)SingletonComponent <ServerMgr> .Instance).persistance.SetPlayerInfo(this.baseEntity.userID, playerInfo);
             }
         }
     }
     this.baseEntity.SendNetworkUpdateImmediate(false);
     this.baseEntity.ClientRPCPlayer <int>((Connection)null, this.baseEntity, "UnlockedBlueprint", 0);
 }
Ejemplo n.º 14
0
 private PersistantPlayer FetchFromDatabase(ulong playerID)
 {
     try
     {
         Row row = UserPersistance.blueprints.QueryRow("SELECT info FROM data WHERE userid = ?", new object[1]
         {
             (object)playerID.ToString()
         });
         if (row != null)
         {
             return(PersistantPlayer.Deserialize(row.GetBlob("info")));
         }
     }
     catch (Exception ex)
     {
         Debug.LogError((object)("Error loading player blueprints: (" + ex.Message + ")"));
     }
     return((PersistantPlayer)null);
 }
Ejemplo n.º 15
0
    public void UnlockAll()
    {
        foreach (ItemBlueprint itemBlueprint in ItemManager.bpList)
        {
            if (!itemBlueprint.userCraftable || itemBlueprint.defaultBlueprint)
            {
                continue;
            }
            PersistantPlayer playerInfo = SingletonComponent <ServerMgr> .Instance.persistance.GetPlayerInfo(base.baseEntity.userID);

            if (playerInfo.unlockedItems.Contains(itemBlueprint.targetItem.itemid))
            {
                continue;
            }
            playerInfo.unlockedItems.Add(itemBlueprint.targetItem.itemid);
            SingletonComponent <ServerMgr> .Instance.persistance.SetPlayerInfo(base.baseEntity.userID, playerInfo);
        }
        base.baseEntity.SendNetworkUpdateImmediate(false);
        base.baseEntity.ClientRPCPlayer <int>(null, base.baseEntity, "UnlockedBlueprint", 0);
    }
Ejemplo n.º 16
0
    public void RPC_BeginExperiment(BaseEntity.RPCMessage msg)
    {
        BasePlayer basePlayer = msg.player;

        if (basePlayer == null)
        {
            return;
        }
        if (this.IsWorking())
        {
            return;
        }
        PersistantPlayer playerInfo = SingletonComponent <ServerMgr> .Instance.persistance.GetPlayerInfo(basePlayer.userID);

        int num  = UnityEngine.Random.Range(0, (int)this.experimentalItems.subSpawn.Length);
        int num1 = 0;

        while (num1 < (int)this.experimentalItems.subSpawn.Length)
        {
            int length = num1 + num;
            if (length >= (int)this.experimentalItems.subSpawn.Length)
            {
                length -= (int)this.experimentalItems.subSpawn.Length;
            }
            ItemDefinition itemDefinition = this.experimentalItems.subSpawn[length].category.items[0].itemDef;
            if (!itemDefinition.Blueprint || itemDefinition.Blueprint.defaultBlueprint || !itemDefinition.Blueprint.userCraftable || !itemDefinition.Blueprint.isResearchable || itemDefinition.Blueprint.NeedsSteamItem || playerInfo.unlockedItems.Contains(itemDefinition.itemid))
            {
                num1++;
            }
            else
            {
                this.pendingBlueprint = itemDefinition;
                break;
            }
        }
        if (this.pendingBlueprint == null)
        {
            basePlayer.ChatMessage("You have already unlocked everything for this workbench tier.");
            return;
        }
        if (Interface.CallHook("CanExperiment", basePlayer, this) != null)
        {
            return;
        }
        Item slot = this.inventory.GetSlot(0);

        if (slot != null)
        {
            if (!slot.MoveToContainer(basePlayer.inventory.containerMain, -1, true))
            {
                slot.Drop(this.GetDropPosition(), this.GetDropVelocity(), new Quaternion());
            }
            basePlayer.inventory.loot.SendImmediate();
        }
        if (this.experimentStartEffect.isValid)
        {
            Effect.server.Run(this.experimentStartEffect.resourcePath, this, 0, Vector3.zero, Vector3.zero, null, false);
        }
        base.SetFlag(BaseEntity.Flags.On, true, false, true);
        this.inventory.SetLocked(true);
        base.CancelInvoke(new Action(this.ExperimentComplete));
        base.Invoke(new Action(this.ExperimentComplete), 5f);
        base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
    }