示例#1
0
 public void AddBehaviour( ObjectBehaviour beh )
 {
     try
     {
         __behaviourTable.Add( beh.name, beh );
     }
     catch ( Exception )
     {
     }
 }
示例#2
0
 // Use this for initialization
 void Start()
 {
     timeCount = 0.0f;
     testMod   = GetComponent <ObjectBehaviour>();
 }
示例#3
0
        public void DestroyItem(ObjectBehaviour item, HashSet <GameObject> alreadySold)
        {
            //already sold this this sales cycle.
            if (alreadySold.Contains(item.gameObject))
            {
                return;
            }
            var storage = item.GetComponent <InteractableStorage>();

            if (storage)
            {
                foreach (var slot in storage.ItemStorage.GetItemSlots())
                {
                    if (slot.Item)
                    {
                        DestroyItem(slot.Item.GetComponent <ObjectBehaviour>(), alreadySold);
                    }
                }
            }

            //note: it seems the held items are also detected in UnloadCargo as being on the matrix but only
            //when they were spawned or moved onto that cargo shuttle (outside of the crate) prior to being placed into the crate. If they
            //were instead placed into the crate and then the crate was moved onto the cargo shuttle, they
            //will only be found with this check and won't be found in UnloadCargo.
            //TODO: Better logic for ClosetControl updating its held items' parent matrix when crossing matrix with items inside.
            var closet = item.GetComponent <ClosetControl>();

            if (closet)
            {
                foreach (var closetItem in closet.ServerHeldItems)
                {
                    DestroyItem(closetItem, alreadySold);
                }
            }

            // If there is no bounty for the item - we dont destroy it.
            var credits = Instance.GetSellPrice(item);

            Credits += credits;
            OnCreditsUpdate?.Invoke();

            var    attributes = item.gameObject.GetComponent <Attributes>();
            string exportName = System.String.Empty;

            if (attributes)
            {
                if (string.IsNullOrEmpty(attributes.ExportName))
                {
                    exportName = attributes.ArticleName;
                }
                else
                {
                    exportName = attributes.ExportName;
                }
            }
            else
            {
                exportName = item.gameObject.ExpensiveName();
            }
            ExportedItem export;

            if (exportedItems.ContainsKey(exportName))
            {
                export = exportedItems[exportName];
            }
            else
            {
                export = new ExportedItem
                {
                    ExportMessage = attributes ? attributes.ExportMessage : "",
                    ExportName    = attributes ? attributes.ExportName : ""                  // Need to always use the given export name
                };
                exportedItems.Add(exportName, export);
            }

            var stackable = item.gameObject.GetComponent <Stackable>();
            var count     = 1;

            if (stackable)
            {
                count = stackable.Amount;
            }

            export.Count      += count;
            export.TotalValue += credits;

            var playerScript = item.GetComponent <PlayerScript>();

            if (playerScript != null)
            {
                playerScript.playerHealth.ServerGibPlayer();
            }

            item.registerTile.UnregisterClient();
            item.registerTile.UnregisterServer();
            alreadySold.Add(item.gameObject);
            Despawn.ServerSingle(item.gameObject);
        }
        public override void Apply(MonoBehaviour sender, float amount)
        {
            // Following function uses the code from the Explosions file.

            // Get data from container before despawning
            ObjectBehaviour objectBehaviour = sender.GetComponent <ObjectBehaviour>();
            RegisterObject  registerObject  = sender.GetComponent <RegisterObject>();
            BodyPart        bodyPart        = sender.GetComponent <BodyPart>();

            bool insideBody = false;

            if (bodyPart != null && bodyPart.HealthMaster != null)
            {
                insideBody = true;
            }



            // Based on radius calculation in Explosions\Explosion.cs, where an amount of 30u will have an
            // explosion radius of 1. Strength is determined using a logarthmic formula to cause diminishing returns.
            var strength = (float)(-463 + 205 * Mathf.Log(amount) + 75 * Math.PI) * potency;


            if (insideBody && strength > 0)
            {
                if (strength >= bodyPart.Health)
                {
                    float temp = bodyPart.Health;                     //temporary store to make sure we don't use an updated health when decrementing strength
                    bodyPart.TakeDamage(null, temp, AttackType.Internal, DamageType.Brute);
                    strength -= temp;
                }
                else
                {
                    bodyPart.TakeDamage(null, strength, AttackType.Internal, DamageType.Brute);
                    strength = 0;
                }

                foreach (BodyPart part in bodyPart.HealthMaster.BodyPartList)
                {
                    if (strength >= part.Health)
                    {
                        float temp = part.Health;                         //temporary store to make sure we don't use an updated health when decrementing strength
                        part.TakeDamage(null, temp, AttackType.Internal, DamageType.Brute);
                        strength -= temp;
                    }
                    else
                    {
                        part.TakeDamage(null, strength, AttackType.Internal, DamageType.Brute);
                        strength = 0;
                    }
                }
            }

            // Explosion here
            var picked = sender.GetComponent <Pickupable>();

            if (picked != null)
            {
                //If sender is in an inventory use the position of the inventory.
                if (picked.ItemSlot != null)
                {
                    objectBehaviour = picked.ItemSlot.ItemStorage.GetRootStorageOrPlayer().GetComponent <ObjectBehaviour>();
                    registerObject  = picked.ItemSlot.ItemStorage.GetRootStorageOrPlayer().GetComponent <RegisterObject>();
                }
            }

            if (strength > 0)
            {
                //Check if this is happening inside of an Object first (machines, closets?)
                if (registerObject == null)
                {
                    //If not, we need to check if the item is a bodypart inside of a player
                    if (insideBody)
                    {
                        Explosion.StartExplosion(bodyPart.HealthMaster.RegisterTile.WorldPosition, strength,
                                                 bodyPart.HealthMaster.RegisterTile.Matrix);
                    }
                    else
                    {
                        //Otherwise, if it's not inside of a player, we consider it just an item
                        Explosion.StartExplosion(objectBehaviour.registerTile.LocalPosition, strength,
                                                 objectBehaviour.registerTile.Matrix);
                    }
                }
                else
                {
                    Explosion.StartExplosion(registerObject.LocalPosition, strength,
                                             registerObject.Matrix);
                }
            }

            // If sender is a pickupable item not inside the body, destroy it.
            if (picked != null && !insideBody)
            {
                Despawn.ServerSingle(sender.gameObject);
            }
        }
 public virtual void TransportObjectsItems(ObjectBehaviour objectsitems)
 {
     objectsitems.GetComponent <CustomNetTransform>().SetPosition(SelectedWorld.GetComponent <RegisterTile>().WorldPosition);
 }
示例#6
0
 void PushObject(ObjectBehaviour entity, Vector3 pushVector)
 {
     entity.QueuePush(pushVector.NormalizeTo2Int());
     //entity.TryPush(pushVector.NormalizeTo2Int());
     //GetComponent<CustomNetTransform>().Push(pushVector.NormalizeTo2Int());
 }
示例#7
0
 void Awake()
 {
     Matrix             = gameObject.RegisterTile().Matrix;
     ContainerBehaviour = GetComponent <ObjectBehaviour>();
 }
示例#8
0
 public void AddObject(ObjectBehaviour entity)
 {
     containedObjects.Add(entity);
     SetContainerAndMakeInvisible(entity);
 }
示例#9
0
 public void AddPlayer(ObjectBehaviour player)
 {
     containedPlayers.Add(player);
     SetContainerAndMakeInvisible(player);
     FollowCameraMessage.Send(player.gameObject, gameObject);
 }
示例#10
0
 public virtual void TransportPlayers(ObjectBehaviour player)
 {
     //teleports player to the next tile
     player.GetComponent <PlayerSync>().SetPosition(registerTile.WorldPosition + position);
 }
示例#11
0
 public virtual void Transport(ObjectBehaviour toTransport)
 {
     toTransport.GetComponent <CustomNetTransform>().SetPosition(registerTile.WorldPosition + position);
 }
示例#12
0
		private void PushObject(ObjectBehaviour entity, Vector3 pushVector)
		{
			//Push Twice
			entity.QueuePush(pushVector.NormalizeTo2Int());
			entity.QueuePush(pushVector.NormalizeTo2Int());
		}
        private void CheckPlayerCrawlState(ObjectBehaviour playerBehaviour)
        {
            var regPlayer = playerBehaviour.GetComponent <RegisterPlayer>();

            regPlayer.HandleGetupAnimation(!regPlayer.IsLayingDown);
        }
示例#14
0
 void Awake()
 {
     storageObj      = GetComponent <StorageObject>();
     objectBehaviour = GetComponent <ObjectBehaviour>();
 }
示例#15
0
 public void ServerAddInternalItem(ObjectBehaviour toAdd)
 {
     ServerAddInternalItemInternal(toAdd);
 }
示例#16
0
 void SetContainerAndMakeInvisible(ObjectBehaviour entity)
 {
     entity.parentContainer = ContainerBehaviour;
     entity.VisibleState    = false;
 }
示例#17
0
 private void Awake()
 {
     this.customNetTransform = GetComponent <CustomNetTransform>();
     this.objectBehaviour    = GetComponent <ObjectBehaviour>();
     this.registerTile       = GetComponent <RegisterTile>();
 }
示例#18
0
 private void Awake()
 {
     registerTile      = gameObject.RegisterTile();
     tileChangeManager = registerTile.TileChangeManager;
     behaviour         = GetComponent <ObjectBehaviour>();
 }
示例#19
0
 void PushPlayer(ObjectBehaviour player, Vector3 pushVector)
 {
     //PushObject(player, pushVector);
     player.GetComponent <RegisterPlayer>()?.ServerStun();
     player.QueuePush(pushVector.NormalizeTo2Int());
 }
示例#20
0
 private void Start()
 {
     registerObject = GetComponent <RegisterObject>();
     GetComponent <Integrity>().OnWillDestroyServer.AddListener(OnWillDestroyServer);
     objectBehaviour = GetComponent <ObjectBehaviour>();
 }
示例#21
0
 public void AddItem(ObjectBehaviour item)
 {
     containedItems.Add(item);
     SetContainerAndMakeInvisible(item);
 }
示例#22
0
 private void Awake()
 {
     registerTile    = GetComponent <RegisterTile>();
     objectBehaviour = GetComponent <ObjectBehaviour>();
 }
示例#23
0
 public void RemoveBehaviour( ObjectBehaviour beh )
 {
     __behaviourTable.Remove( beh.name );
 }
 public virtual void TransportPlayers(ObjectBehaviour player)
 {
     //teleports player to the front of the new gateway
     player.GetComponent <PlayerSync>().SetPosition(SelectedWorld.GetComponent <RegisterTile>().WorldPosition);
 }