public void Copy(InventoryActionDataObject _data) { if (_data == null) { return; } base.Copy(_data); Type = _data.Type; ItemName = _data.ItemName; ParentName = _data.ParentName; DistributionOffset = _data.DistributionOffset; DistributionRotation = _data.DistributionRotation; DistributionOffsetType = _data.DistributionOffsetType; DistributionOffsetRadius = _data.DistributionOffsetRadius; }
public InventoryActionDataObject(InventoryActionDataObject _data) : base(_data) { Copy(_data); }
public void Action(InventoryActionDataObject _action) { if (_action == null || !_action.Enabled) { return; } if (_action.DropItemRequired()) { InventorySlotObject _slot = GetSlotByItemName(_action.ItemName); if (_slot != null && _slot.Amount > 0) { Transform _transform = ICE.World.Utilities.SystemTools.FindChildByName(_action.ParentName, Owner.transform); _transform = (_transform != null ? _transform : Owner.transform); Quaternion _rotation = Quaternion.Euler(0, UnityEngine.Random.Range(0, 360), 0); Vector3 _position = PositionTools.FixTransformPoint(_transform, _action.Offset); GameObject _item = _slot.GiveItem(_position, _rotation); if (_item == null) { _item = CreatureRegister.Spawn(_slot.ItemReferenceObject, _position, _rotation); _slot.Amount--; } } } else if (_action.ParentUpdateRequired()) { InventorySlotObject _slot = GetSlotByItemName(_action.ItemName); if (_slot != null && _slot.Amount > 0) { if (_slot.ItemObject != null) { _slot.MountPointName = _action.ParentName; } } } else if (_action.CollectActiveItemRequired()) { ICECreatureControl _control = OwnerComponent as ICECreatureControl; TargetObject _target = _control.Creature.ActiveTarget; if (_control != null && _target != null && _target.Selectors.TotalCheckIsValid) //&& LastCollectedObjectID != _target.TargetID ) { GameObject _item = _target.TargetGameObject; //LastCollectedObjectID = _target.TargetID; if (_target.EntityComponent != null && _target.EntityComponent.IsChildEntity) { ICEWorldEntity _parent = _target.EntityComponent.RootEntity; if (_parent != null) { if (DebugLogIsEnabled) { PrintDebugLog(this, "CollectActiveItem : take '" + _target.Name + "' from " + _parent.name + " (" + _parent.ObjectInstanceID + ")"); } InventorySlotObject _slot = GetInventorySlot(_parent.gameObject, _target.TargetName); if (_slot != null) { _item = _slot.GiveItem(); } } } if (Insert(_item)) { //Debug.Log( _control.Creature.ActiveTarget.TargetGameObject.name + " - " + _control.Creature.ActiveTarget.TargetGameObject.GetInstanceID() ); //_target.ResetTargetGameObject(); _control.Creature.ResetActiveTarget(); // } } } }