Beispiel #1
0
        public static UNetClientEquipmentCollection <IEquippableItemInstance> CreateClientEquipmentCollection(
            string collectionName,
            System.Guid collectionGuid,
            NetworkIdentity owner,
            UNetActionsBridge playerBridge,
            EquipmentCollectionSlot <IEquippableItemInstance>[] slots,
            IEquippableCharacter <IEquippableItemInstance> character)
        {
            var collection = new UNetClientEquipmentCollection <IEquippableItemInstance>(owner, playerBridge, 0, character)
            {
                collectionName = collectionName,
                ID             = collectionGuid
            };

            collection.slots = slots;
            for (int i = 0; i < collection.slots.Length; i++)
            {
                collection.slots[i].collection = collection;
                collection.slots[i].index      = i;
            }

            collection.Register();

            // The server's owner object always has read/write permission.
            UNetPermissionsRegistry.collections.SetPermission(collection, owner, ReadWritePermission.None);

            _logger.Log($"[Server] Created and registered equipment collection with name {collection.collectionName} and guid {collection.ID} for netID: {owner.netId}", collection);
            return(collection);
        }
Beispiel #2
0
        private UNetCollectionBase <IItemInstance> GetCollection(UNetActionsBridge bridge)
        {
            // The collection belongs to this identity
            var cols = UNetPermissionsRegistry.collections.GetAllWithPermission(_identity);
            var triggerCollection = cols.FirstOrDefault(o => o.obj.collectionName == _collectionName);

            if (triggerCollection.obj != null)
            {
                // NOTE: The collection belongs to this object's network identity.
                // NOTE: We're handling the lifetime of the object and handle registration of the collection on clients.
                return(triggerCollection.obj as UNetCollectionBase <IItemInstance>);
            }

            // The collection belongs to the player using this trigger
            var cols2            = UNetPermissionsRegistry.collections.GetAllWithPermission(bridge.identity);
            var playerCollection = cols2.FirstOrDefault(o => o.obj.collectionName == _collectionName);

            return(playerCollection.obj as UNetCollectionBase <IItemInstance>);
        }
 public UNetCollectionReplicator(UNetActionsBridge bridge, ILogger logger = null)
 {
     this.bridge = bridge;
     this.logger = logger ?? new UnityLogger("[UNet] ");
 }
Beispiel #4
0
 public UNetClientEquipmentCollection(NetworkIdentity owner, UNetActionsBridge actionBridge, int slotCount, IEquippableCharacter <TEquippableType> character, ILogger logger = null)
     : base(slotCount, character, logger)
 {
     this.actionBridge = actionBridge;
     this.owner        = owner;
 }
        public static UNetClientCurrencyCollection CreateClientCurrencyCollection(string collectionName, System.Guid collectionGuid, NetworkIdentity owner, UNetActionsBridge playerBridge)
        {
            var collection = new UNetClientCurrencyCollection(owner, playerBridge, _logger)
            {
                collectionName = collectionName,
                ID             = collectionGuid
            };

            collection.Register();

            // Set permission for this client; If we own it it will be added to the registry list.
            UNetPermissionsRegistry.collections.SetPermission(collection, playerBridge.identity, ReadWritePermission.None);

            _logger.Log($"[Client] Created and registered currency collection with name {collection.collectionName} and guid {collection.ID} for netID: {owner.netId}", collection);
            return(collection);
        }
Beispiel #6
0
        public static UNetClientCollection <IVendorProduct <IItemInstance> > CreateClientVendorItemCollection(int slotCount, string collectionName, System.Guid collectionGuid, NetworkIdentity owner, UNetActionsBridge playerBridge)
        {
            var collection = new UNetClientCollection <IVendorProduct <IItemInstance> >(owner, playerBridge, slotCount)
            {
                collectionName = collectionName,
                ID             = collectionGuid
            };

            collection.Register();

            // NOTE: Do not give the player read+write access to the vendor collection; That way the client could set items directly into the vendor collection.
            UNetPermissionsRegistry.collections.SetPermission(collection, owner, ReadWritePermission.Read);

            _logger.Log($"[Client] Created and registered vendor item collection with name {collectionName} and guid {collectionGuid} for netID: {owner.netId}", collection);
            return(collection);
        }
Beispiel #7
0
 protected override void OnEnable()
 {
     bridge = GetComponent <UNetActionsBridge>();
     // base.OnEnable();
 }
Beispiel #8
0
 public UNetClientCurrencyCollection(NetworkIdentity owner, UNetActionsBridge actionsBridge, ILogger logger = null)
     : base(owner, logger)
 {
     this.actionsBridge = actionsBridge;
 }
 public UNetClientCollection(NetworkIdentity owner, UNetActionsBridge actionBridge, int slotCount, ILogger logger = null)
     : base(owner, slotCount, logger)
 {
     this.actionBridge = actionBridge;
 }