Example #1
0
 private static bool GetCharacterStuff(ref ConsoleSystem.Arg args, out Character character, out CameraMount camera, out ItemRepresentation itemRep, out ArmorModelRenderer armor)
 {
     character = null;
     itemRep = null;
     armor = null;
     camera = CameraMount.current;
     if (!camera)
     {
         args.ReplyWith("Theres no active camera mount.");
         return false;
     }
     character = IDBase.GetMain(camera) as Character;
     if (!character)
     {
         args.ReplyWith("theres no character for the current mounted camera");
         return false;
     }
     armor = character.GetLocal<ArmorModelRenderer>();
     InventoryHolder local = character.GetLocal<InventoryHolder>();
     if (local)
     {
         itemRep = local.itemRepresentation;
     }
     return true;
 }
Example #2
0
 public BulletWeaponImpact(BulletWeaponDataBlock dataBlock, IBulletWeaponItem item, ItemRepresentation itemRep, Transform hitTransform, Vector3 localHitPoint, Vector3 localHitDirection)
     : base(dataBlock, item, itemRep)
 {
     this.hitTransform = hitTransform;
     this.hitPoint = localHitPoint;
     this.hitDirection = localHitDirection;
 }
Example #3
0
 public void Init(float arrowSpeed, ItemRepresentation itemRep, IBowWeaponItem itemInstance, bool firedLocal)
 {
     this.speedPerSec = arrowSpeed;
     if (itemRep != null && itemInstance != null)
     {
         this._myBow = itemRep;
         this._myItemInstance = itemInstance;
     }
 }
Example #4
0
 public override void DoAction3(uLink.BitStream stream, ItemRepresentation itemRep, ref uLink.NetworkMessageInfo info)
 {
     this.StartSwingWorldAnimations(itemRep);
 }
Example #5
0
 // privatescope
 internal void IHeldItem.set_itemRepresentation(ItemRepresentation value)
 {
     base.itemRepresentation = value;
 }
Example #6
0
    public override void DoAction1(uLink.BitStream stream, ItemRepresentation rep, ref uLink.NetworkMessageInfo info)
    {
        Vector3 vector3 = stream.ReadVector3();

        this.FireArrow(vector3, stream.ReadQuaternion(), rep, null);
    }
Example #7
0
    public override void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        bool      flag;
        Socket    socket;
        Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray ray = character.eyesRay;
        int num = 1;

        itemInstance.Consume(ref num);
        uLink.BitStream bitStream   = new uLink.BitStream(false);
        float           bulletRange = this.GetBulletRange(itemRep);

        for (int i = 0; i < this.numPellets; i++)
        {
            Ray ray1 = ray;
            ray1.direction = (Quaternion.LookRotation(ray.direction) * Quaternion.Euler(UnityEngine.Random.Range(-this.xSpread, this.xSpread), UnityEngine.Random.Range(-this.ySpread, this.ySpread), 0f)) * Vector3.forward;
            Component component = null;
            this.FireSingleBullet(bitStream, ray1, itemRep, out component, out flag);
            this.MakeTracer(ray1.origin, ray1.origin + (ray1.direction * bulletRange), bulletRange, component, flag);
        }
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
        bool flag1 = vm;

        if (!flag1)
        {
            socket = itemRep.muzzle;
        }
        else
        {
            socket = vm.muzzle;
        }
        this.DoWeaponEffects(character.transform, socket, flag1, itemRep);
        if (flag1)
        {
            vm.PlayFireAnimation();
        }
        float single = 1f;

        if (sample.aim)
        {
            single = single - this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            single = single - this.crouchRecoilSubtract;
        }
        float            single1          = UnityEngine.Random.Range(this.recoilPitchMin, this.recoilPitchMax) * single;
        float            single2          = UnityEngine.Random.Range(this.recoilYawMin, this.recoilYawMax) * single;
        RecoilSimulation recoilSimulation = character.recoilSimulation;

        if (recoilSimulation)
        {
            recoilSimulation.AddRecoil(this.recoilDuration, single1, single2);
        }
        HeadBob headBob = CameraMount.current.GetComponent <HeadBob>();

        if (headBob && this.shotBob)
        {
            headBob.AddEffect(this.shotBob);
        }
    }
Example #8
0
 public WeaponImpact(WeaponDataBlock dataBlock, IWeaponItem item, ItemRepresentation itemRep)
 {
     this.dataBlock = dataBlock;
     this.item = item;
     this.itemRep = itemRep;
 }
Example #9
0
 public virtual void Local_DryFire(ViewModel vm, ItemRepresentation itemRep)
 {
     this.dryFireSound.PlayLocal(itemRep.transform, Vector3.zero, 1f, 0);
 }
Example #10
0
 public override void DoAction2(BitStream stream, ItemRepresentation itemRep, ref NetworkMessageInfo info)
 {
 }
Example #11
0
 public static void StructureComponentAction(uLink.BitStream stream, ItemRepresentation rep, ref uLink.NetworkMessageInfo info, StructureComponentDataBlock SCDB)
 {
     uLink.NetworkPlayer netPlayer = info.sender;
     PlayerClient playerClient = Array.Find(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.netPlayer == netPlayer);
     IStructureComponentItem item;
     NetCull.VerifyRPC(ref info);
     if (rep.Item<IStructureComponentItem>(out item) && (item.uses > 0))
     {
         StructureComponent structureToPlacePrefab = SCDB.structureToPlacePrefab;
         Vector3 origin = stream.ReadVector3();
         Vector3 direction = stream.ReadVector3();
         Vector3 position = stream.ReadVector3();
         Quaternion rotation = stream.ReadQuaternion();
         uLink.NetworkViewID viewID = stream.ReadNetworkViewID();
         StructureMaster component = null;
         if (nearZone(position) && !buildList.Contains(playerClient.userID.ToString()))
         {
             Rust.Notice.Popup(info.sender, "", "You can't place that near safe zones or war zones.", 4f);
         }
         else
         {
             if (viewID == uLink.NetworkViewID.unassigned)
             {
                 if (SCDB.MasterFromRay(new Ray(origin, direction)))
                 {
                     return;
                 }
                 if (structureToPlacePrefab.type != StructureComponent.StructureComponentType.Foundation)
                 {
                     Debug.Log("ERROR, tried to place non foundation structure on terrain!");
                 }
                 else
                 {
                     component = NetCull.InstantiateClassic<StructureMaster>(Bundling.Load<StructureMaster>("content/structures/StructureMasterPrefab"), position, rotation, 0);
                     component.SetupCreator(item.controllable);
                 }
             }
             else
             {
                 component = uLink.NetworkView.Find(viewID).gameObject.GetComponent<StructureMaster>();
             }
             if (component == null)
             {
                 Debug.Log("NO master, something seriously wrong");
             }
             else if (SCDB._structureToPlace.CheckLocation(component, position, rotation) && SCDB.CheckBlockers(position))
             {
                 StructureComponent comp = NetCull.InstantiateStatic(SCDB.structureToPlaceName, position, rotation).GetComponent<StructureComponent>();
                 if (comp != null)
                 {
                     component.AddStructureComponent(comp);
                     int count = 1;
                     if (item.Consume(ref count))
                     {
                         item.inventory.RemoveItem(item.slot);
                     }
                 }
             }
         }
     }
 }
 private void OnDestroy()
 {
     if (this._modSlot != -2)
     {
         try
         {
             if (this._modSlot != -1)
             {
                 if (!this._itemRep)
                 {
                     this._itemRep = null;
                 }
                 else
                 {
                     try
                     {
                         if ((byte)(this.caps & ItemModRepresentation.Caps.Shutdown) == 128)
                         {
                             try
                             {
                                 this.Shutdown();
                             }
                             catch (Exception exception)
                             {
                                 Debug.LogError(exception, this);
                             }
                         }
                         try
                         {
                             this._itemRep.ItemModRepresentationDestroyed(this);
                         }
                         catch (Exception exception1)
                         {
                             Debug.LogError(exception1, this);
                         }
                     }
                     finally
                     {
                         this._itemRep = null;
                     }
                 }
             }
         }
         finally
         {
             this._modSlot = -2;
         }
     }
 }
Example #13
0
 internal void SetItemRepresentation(ItemRepresentation value)
 {
     if (this.itemRep != value)
     {
         this.itemRep = value;
         this.hasItem = this.itemRep;
         if (!this.hasItem)
         {
             this._animationGroupNameCached = null;
         }
         else
         {
             this._animationGroupNameCached = this.itemRep.worldAnimationGroupName;
             if (this._animationGroupNameCached != null && this._animationGroupNameCached.Length == 1)
             {
                 this._animationGroupNameCached = null;
             }
         }
     }
 }
Example #14
0
 internal void ClearItemRepresentation(ItemRepresentation value)
 {
     if (this.hasItem && this.itemRep == value)
     {
         this.itemRep = null;
         this.hasItem = false;
         this._animationGroupNameCached = null;
     }
 }
Example #15
0
 private void SetViewModel(ViewModel vm, ItemRepresentation rep, IHeldItem item)
 {
     if (!this.awoke)
     {
         this.viewModel = vm;
         this.rep = rep;
         this.item = item;
         return;
     }
     if (this.viewModel != vm)
     {
         if (this.viewModel)
         {
             if (this.viewModel.itemRep)
             {
                 try
                 {
                     this.viewModel.itemRep.UnBindViewModel(this.viewModel, this.viewModel.item);
                 }
                 catch (Exception exception)
                 {
                     Debug.LogException(exception, this.viewModel.itemRep);
                 }
             }
             this.viewModel.UnBindTransforms();
             this.viewModel.idMain = null;
         }
         this.viewModel = vm;
         if (vm)
         {
             if (!CameraFX.viewModelRootTransform)
             {
                 Transform gameObject = (new GameObject("__View Model Root")).transform;
                 CameraFX.viewModelRootTransform = (new GameObject("Eye Camera Difference")).transform;
                 CameraFX.viewModelRootTransform.parent = gameObject;
             }
             vm.idMain = this.idMain;
             vm.transform.parent = CameraFX.viewModelRootTransform;
             if (rep)
             {
                 rep.PrepareViewModel(vm, item);
             }
             vm.BindTransforms(CameraFX.viewModelRootTransform, base.transform.parent);
             if (rep)
             {
                 rep.BindViewModel(vm, item);
                 vm.itemRep = rep;
                 vm.item = item;
             }
         }
         for (int i = (int)this._effects.Length - 1; i >= 0; i--)
         {
             if (this._effects[i])
             {
                 this.effects[i].OnViewModelChange(vm);
             }
         }
     }
 }
Example #16
0
 protected new void Awake()
 {
     this.camera = base.camera;
     this.adaptiveNearPlane = base.GetComponent<AdaptiveNearPlane>();
     int num = 0;
     if (this._effects != null && (int)this._effects.Length != 0)
     {
         for (int i = 0; i < (int)this._effects.Length; i++)
         {
             if (!this._effects[i] || !(this._effects[i] is ICameraFX))
             {
                 Debug.LogWarning(string.Concat("effect at index ", i, " is missing, null or not a ICameraFX"), this);
             }
             else
             {
                 int num1 = num;
                 num = num1 + 1;
                 this._effects[num1] = this._effects[i];
             }
         }
     }
     Array.Resize<MonoBehaviour>(ref this._effects, num);
     Array.Resize<ICameraFX>(ref this.effects, num);
     if (num != 0)
     {
         for (int j = 0; j < num; j++)
         {
             this.effects[j] = (ICameraFX)this._effects[j];
         }
     }
     else
     {
         Debug.LogWarning("There are no effects", this);
     }
     this.awoke = true;
     if (this.viewModel)
     {
         ViewModel viewModel = this.viewModel;
         this.viewModel = null;
         ItemRepresentation itemRepresentation = this.rep;
         this.rep = null;
         IHeldItem heldItem = this.item;
         this.item = null;
         this.SetViewModel(viewModel, itemRepresentation, heldItem);
     }
     base.Awake();
 }
Example #17
0
 public static void ReplaceViewModel(ViewModel vm, ItemRepresentation rep, IHeldItem item, bool butDontDestroyOld)
 {
     CameraFX cameraFX = CameraFX.mainCameraFX;
     if (cameraFX && cameraFX.viewModel != vm)
     {
         ViewModel viewModel = cameraFX.viewModel;
         cameraFX.SetViewModel(vm, rep, item);
         if (!butDontDestroyOld && viewModel)
         {
             UnityEngine.Object.Destroy(viewModel.gameObject);
         }
     }
 }
Example #18
0
 public BulletWeaponImpact(BulletWeaponDataBlock dataBlock, IBulletWeaponItem item, ItemRepresentation itemRep, Vector3 worldHitPoint, Vector3 worldHitDirection)
     : this(dataBlock, item, itemRep, null, worldHitPoint, worldHitDirection)
 {
 }
Example #19
0
    public virtual void Local_MidSwing(ViewModel vm, ItemRepresentation itemRep, IMeleeWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        BodyPart  bodyPart;
        IDBase    dBase;
        IDMain    dMain;
        Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        Ray         ray         = character.eyesRay;
        bool        flag        = false;
        Collider    collider    = null;
        Vector3     vector3     = Vector3.zero;
        Vector3     vector31    = Vector3.up;
        NetEntityID netEntityID = NetEntityID.unassigned;
        bool        flag1       = false;

        flag = this.Physics2SphereCast(ray, 0.3f, this.GetRange(), 406721553, out vector3, out vector31, out collider, out bodyPart);
        bool       flag2     = false;
        TakeDamage component = null;

        if (flag)
        {
            TransformHelpers.GetIDBaseFromCollider(collider, out dBase);
            if (!dBase)
            {
                dMain = null;
            }
            else
            {
                dMain = dBase.idMain;
            }
            IDMain dMain1 = dMain;
            if (dMain1)
            {
                netEntityID = NetEntityID.Get(dMain1);
                flag1       = !netEntityID.isUnassigned;
                component   = dMain1.GetComponent <TakeDamage>();
                if (component && component.ShouldPlayHitNotification())
                {
                    this.PlayHitNotification(vector3, character);
                }
            }
            flag2 = collider.gameObject.CompareTag("Tree Collider");
            if (flag2)
            {
                WoodBlockerTemp blockerForPoint = WoodBlockerTemp.GetBlockerForPoint(vector3);
                if (blockerForPoint.HasWood())
                {
                    blockerForPoint.ConsumeWood(this.efficiencies[2]);
                }
                else
                {
                    flag2 = false;
                    Notice.Popup("", "There's no wood left here", 2f);
                }
            }
            this.DoMeleeEffects(ray.origin, vector3, Quaternion.LookRotation(vector31), collider.gameObject);
            if (vm && (component || flag2))
            {
                vm.CrossFade("pull_out", 0.05f, PlayMode.StopSameLayer, 1.1f);
            }
        }
        uLink.BitStream bitStream = new uLink.BitStream(false);
        if (!flag1)
        {
            bitStream.WriteBoolean(false);
            bitStream.WriteVector3(vector3);
        }
        else
        {
            bitStream.WriteBoolean(flag1);
            bitStream.Write <NetEntityID>(netEntityID, new object[0]);
            bitStream.WriteVector3(vector3);
        }
        bitStream.WriteBoolean(flag2);
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
        this.EndSwingWorldAnimations(itemRep);
    }
Example #20
0
 public virtual bool IsSilenced(ItemRepresentation itemRep)
 {
     return((itemRep.modFlags & ItemModFlags.Audio) == ItemModFlags.Audio);
 }
Example #21
0
 public WeaponImpact(WeaponDataBlock dataBlock, IWeaponItem item, ItemRepresentation itemRep)
 {
     this.dataBlock = dataBlock;
     this.item      = item;
     this.itemRep   = itemRep;
 }
Example #22
0
    public virtual void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Component   component;
        Vector3     point;
        RaycastHit2 hit;
        IDMain      main;
        bool        flag4;
        Socket      muzzle;
        bool        flag5;
        Character   shooterOrNull = itemInstance.character;

        if (shooterOrNull == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray         eyesRay        = shooterOrNull.eyesRay;
        NetEntityID unassigned     = NetEntityID.unassigned;
        bool        hitNetworkView = false;
        int         count          = 1;

        itemInstance.Consume(ref count);
        bool       didHit = Physics2.Raycast2(eyesRay, out hit, this.GetBulletRange(itemRep), 0x183e1411);
        TakeDamage damage = null;

        if (!didHit)
        {
            main      = null;
            point     = eyesRay.GetPoint(1000f);
            component = null;
            goto Label_019E;
        }
        point = hit.point;
        IDBase id = hit.id;

        component = (hit.remoteBodyPart == null) ? ((Component)hit.collider) : ((Component)hit.remoteBodyPart);
        main      = (id == null) ? null : id.idMain;
        if (main == null)
        {
            goto Label_019E;
        }
        unassigned = NetEntityID.Get((MonoBehaviour)main);
        if (unassigned.isUnassigned)
        {
            goto Label_019E;
        }
        hitNetworkView = true;
        damage         = main.GetComponent <TakeDamage>();
        if ((damage != null) && damage.ShouldPlayHitNotification())
        {
            this.PlayHitNotification(point, shooterOrNull);
        }
        bool flag3 = false;

        if (hit.remoteBodyPart != null)
        {
            BodyPart bodyPart = hit.remoteBodyPart.bodyPart;
            switch (bodyPart)
            {
            case BodyPart.Brain:
            case BodyPart.L_Eye:
            case BodyPart.R_Eye:
                break;

            default:
                switch (bodyPart)
                {
                case BodyPart.Head:
                case BodyPart.Jaw:
                    break;

                case BodyPart.Scalp:
                case BodyPart.Nostrils:
                    goto Label_016C;

                default:
                    goto Label_016C;
                }
                break;
            }
            flag3 = true;
        }
        goto Label_0174;
Label_016C:
        flag3 = false;
Label_0174:
        if (flag3)
        {
            this.headshotSound.Play();
        }
Label_019E:
        flag4 = didHit && ((!hit.isHitboxHit || hit.bodyPart.IsDefined()) || (damage != null));
        if (vm != null)
        {
            Socket.Slot slot = vm.socketMap["muzzle"];
            muzzle = slot.socket;
            flag5  = true;
        }
        else
        {
            muzzle = itemRep.muzzle;
            flag5  = false;
        }
        Vector3 position = muzzle.position;

        this.DoWeaponEffects(shooterOrNull.transform, position, point, muzzle, flag5, component, flag4, itemRep);
        if (flag5)
        {
            vm.PlayFireAnimation();
        }
        float num2 = 1f;

        if (sample.aim && sample.crouch)
        {
            num2 -= this.aimingRecoilSubtract + (this.crouchRecoilSubtract * 0.5f);
        }
        else if (sample.aim)
        {
            num2 -= this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            num2 -= this.crouchRecoilSubtract;
        }
        num2 = Mathf.Clamp01(num2);
        float pitch = Random.Range(this.recoilPitchMin, this.recoilPitchMax) * num2;
        float yaw   = Random.Range(this.recoilYawMin, this.recoilYawMax) * num2;

        if (weaponRecoil && (shooterOrNull.recoilSimulation != null))
        {
            shooterOrNull.recoilSimulation.AddRecoil(this.recoilDuration, pitch, yaw);
        }
        HeadBob bob = CameraMount.current.GetComponent <HeadBob>();

        if (((bob != null) && (this.shotBob != null)) && headRecoil)
        {
            bob.AddEffect(this.shotBob);
        }
        BitStream sendStream = new BitStream(false);

        this.WriteHitInfo(sendStream, ref eyesRay, didHit, ref hit, hitNetworkView, unassigned);
        itemRep.ActionStream(1, RPCMode.Server, sendStream);
    }
Example #23
0
 public virtual void DoAction1(BitStream stream, ItemRepresentation rep, ref NetworkMessageInfo info)
 {
 }
Example #24
0
    public virtual void DoWeaponEffects(Transform soundTransform, Vector3 startPos, Vector3 endPos, Socket muzzleSocket, bool firstPerson, Component hitComponent, bool allowBlood, ItemRepresentation itemRep)
    {
        Vector3 forward = endPos - startPos;

        forward.Normalize();
        bool   flag      = this.IsSilenced(itemRep);
        Tracer component = ((GameObject)Object.Instantiate(this.tracerPrefab, startPos, Quaternion.LookRotation(forward))).GetComponent <Tracer>();

        if (component != null)
        {
            component.Init(hitComponent, 0x183e1411, this.GetBulletRange(itemRep), allowBlood);
        }
        if (flag)
        {
            component.startScale = Vector3.zero;
        }
        this.PlayFireSound(soundTransform, firstPerson, itemRep);
        if (!flag)
        {
            Object.Destroy(muzzleSocket.InstantiateAsChild(!firstPerson ? this.muzzleFlashWorld : this.muzzleflashVM, false), 1f);
        }
    }
 public void OnExtinguish(ViewModel vm, ItemRepresentation itemRep, ITorchItem torchItem)
 {
 }
Example #26
0
 public virtual void DoWeaponEffects(Transform soundTransform, Socket muzzleSocket, bool firstPerson, ItemRepresentation itemRep)
 {
     this.PlayFireSound(soundTransform, firstPerson, itemRep);
     UnityEngine.Object.Destroy(muzzleSocket.InstantiateAsChild((!firstPerson ? this.muzzleFlashWorld : this.muzzleflashVM), false), 1f);
 }
 public override void DoAction1(BitStream stream, ItemRepresentation rep, ref NetworkMessageInfo info)
 {
     (rep as TorchItemRep).RepExtinguish();
 }
 public override void DoAction1(uLink.BitStream stream, ItemRepresentation rep, ref uLink.NetworkMessageInfo info)
 {
 }
 public override void DoAction2(BitStream stream, ItemRepresentation itemRep, ref NetworkMessageInfo info)
 {
     this.Ignite(null, itemRep, null);
 }
Example #30
0
 public void ArrowReportMiss(ArrowMovement arrow, ItemRepresentation itemRepresentation)
 {
     uLink.BitStream bitStream = new uLink.BitStream(false);
     bitStream.Write <Vector3>(arrow.transform.position, new object[0]);
     itemRepresentation.ActionStream(3, uLink.RPCMode.Server, bitStream);
 }
 public void DoActualIgnite(ItemRepresentation itemRep, IThrowableItem itemInstance, ViewModel vm)
 {
     this.Ignite(vm, itemRep, this.GetTorchInstance(itemInstance));
     itemRep.Action(2, RPCMode.Server);
 }
Example #32
0
 public virtual void DoWeaponEffects(Transform soundTransform, Vector3 startPos, Vector3 endPos, Socket muzzleSocket, bool firstPerson, Component hitComponent, bool allowBlood, ItemRepresentation itemRep)
 {
 }
 public TorchItemRep GetTorchRep(ItemRepresentation rep)
 {
     return(rep as TorchItemRep);
 }
Example #34
0
 public static void DeployableItemAction(uLink.BitStream stream, ItemRepresentation rep, ref uLink.NetworkMessageInfo info, DeployableItemDataBlock DIDB)
 {
     uLink.NetworkPlayer netPlayer = info.sender;
     PlayerClient playerClient = Array.Find(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.netPlayer == netPlayer);
     IDeployableItem item;
     NetCull.VerifyRPC(ref info);
     if (rep.Item<IDeployableItem>(out item) && (item.uses > 0))
     {
         Vector3 vector3;
         Quaternion quaternion;
         TransCarrier carrier;
         Vector3 origin = stream.ReadVector3();
         Vector3 direction = stream.ReadVector3();
         Ray ray = new Ray(origin, direction);
         if (!DIDB.CheckPlacement(ray, out vector3, out quaternion, out carrier))
         {
             Rust.Notice.Popup(info.sender, "", "You can't place that here.", 4f);
         }
         else
         {
             if (nearZone(vector3) && !buildList.Contains(playerClient.userID.ToString()))
             {
                 Rust.Notice.Popup(info.sender, "", "You can't place that near safe zones or war zones.", 4f);
             }
             else
             {
                 DeployableObject component = NetCull.InstantiateStatic(DIDB.DeployableObjectPrefabName, vector3, quaternion).GetComponent<DeployableObject>(); // Creates model in world space
                 if (component != null)
                 {
                     try
                     {
                         component.SetupCreator(item.controllable); // Sets object variables such as ownerID
                         DIDB.SetupDeployableObject(stream, rep, ref info, component, carrier);
                     }
                     finally
                     {
                         int count = 1;
                         if (item.Consume(ref count))
                         {
                             item.inventory.RemoveItem(item.slot);
                         }
                     }
                 }
             }
         }
     }
 }
Example #35
0
 public virtual void DoAction3(uLink.BitStream stream, ItemRepresentation itemRep, ref uLink.NetworkMessageInfo info)
 {
 }
Example #36
0
 public virtual void Local_CancelStrikes(ViewModel vm, ItemRepresentation itemRep, IStrikeGunItem itemInstance, ref HumanController.InputSample sample)
 {
     vm.CrossFade("idle", 0.15f);
 }
Example #37
0
 public virtual float GetDamage(ItemRepresentation itemRep)
 {
     return(Random.Range(base.damageMin, base.damageMax) * (!this.IsSilenced(itemRep) ? 1f : 0.8f));
 }
        public PhysicalFileParser(string fileLocation)
        {
            //set file name
            ParserName = Path.GetFileNameWithoutExtension(fileLocation);

            // parse the content
            ItemParam = new List<ItemRepresentation>();
            ItemRepresentation prev = null;
            using (StreamReader sr = new StreamReader(fileLocation))
            {
                string line = " ";
                while (line != null)
                {
                    // do the checking of string
                    line = sr.ReadLine();
                    if (line == null)
                        continue;
                    line = line.Trim();
                    if (line.Length <= 0 || line[0] == '#')
                    {
                        continue;
                    }
                    if ((line[0] == '>') && (prev != null))
                    {
                        CompositeItem CI = new CompositeItem();
                        int index = line.IndexOf(',');
                        CI.name = line.Substring(1, index - 1);
                        CI.location = int.Parse(line.Substring(index + 1, line.Length - index - 1));
                        prev.compositeValues.setItem(CI);
                        continue;
                    }
                    prev = null;
                    ItemRepresentation current = new ItemRepresentation();
                    // process the configuration name
                    int SeparatorIndex = line.IndexOf(',');
                    current.ItemName = line.Substring(0, SeparatorIndex);
                    line = line.Substring(SeparatorIndex + 1, line.Length - SeparatorIndex - 1);

                    // process the configuration length
                    SeparatorIndex = line.IndexOf(',');
                    string tempLengthValueHolder;
                    if (SeparatorIndex < 0)
                    {
                        tempLengthValueHolder = line;
                        current.lengthType = ItemRepresentation.LengthType.independent;
                    }
                    else
                    {
                        tempLengthValueHolder = line.Substring(0, SeparatorIndex);

                        string typeOfEntry = line.Substring(SeparatorIndex + 1, line.Length - SeparatorIndex - 1).Trim();
                        switch (typeOfEntry)
                        {
                            case "N":
                                current.valueType = ItemRepresentation.ValueType.normal;
                                current.lengthType = ItemRepresentation.LengthType.affectNext;
                                break;
                            case "C":
                                current.valueType = ItemRepresentation.ValueType.composite;
                                current.compositeValues = new CompositeValue();
                                prev = current;
                                break;
                        }
                    }
                    int lengthValue = Int32.Parse(tempLengthValueHolder);
                    current.ItemLength = lengthValue;
                    // process the configuration next

                    ItemParam.Add((current));
                }
            }
        }
 internal void Initialize(ItemRepresentation itemRep, int modSlot, CharacterStateFlags flags)
 {
     if (this._modSlot != -1)
     {
         if (this._modSlot == -2)
         {
             throw new InvalidOperationException("This ItemModRepresentation has been destroyed");
         }
         if (itemRep != this._itemRep || modSlot < 0 && modSlot < 5 && modSlot != this._modSlot)
         {
             throw new InvalidOperationException(string.Format("The ItemModRepresentation was already initialized with {{\"item\":\"{0}\",\"slot\":{1}}} and cannot be re-initialized to use {{\"item\":\"{2|\",\"slot\":{3}}}", new object[] { this._itemRep, this._modSlot, itemRep, modSlot }));
         }
     }
     else
     {
         if (!itemRep)
         {
             throw new ArgumentOutOfRangeException("itemRep", itemRep, "!itemRep");
         }
         if (modSlot < 0 || modSlot >= 5)
         {
             throw new ArgumentOutOfRangeException("modSlot", (object)modSlot, "modSlot<0||modSlot>=MAX_SUPPORTED_ITEM_MODS");
         }
         this._itemRep = itemRep;
         this._modSlot = modSlot;
         if ((byte)(this.caps & ItemModRepresentation.Caps.Initialize) == 1)
         {
             try
             {
                 this.Initialize();
             }
             catch (Exception exception)
             {
                 this._itemRep = null;
                 this._modSlot = -1;
                 throw;
             }
         }
         this.HandleChangedStateFlags(flags, false);
     }
 }