Beispiel #1
0
        public static void collectBatch(List <GameObject> targets)
        {
            if (targets.Count == 0)
            {
                return;
            }
            HighlighterTool.batchableMaterials.Clear();
            List <GameObject> list = new List <GameObject>();

            HighlighterTool.batchableGameObjects.Add(list);
            for (int i = 0; i < targets.Count; i++)
            {
                GameObject gameObject = targets[i];
                HighlighterTool.lods.Clear();
                gameObject.GetComponentsInChildren <MeshFilter>(HighlighterTool.lods);
                for (int j = 0; j < HighlighterTool.lods.Count; j++)
                {
                    MeshFilter   meshFilter = HighlighterTool.lods[j];
                    MeshRenderer component  = meshFilter.gameObject.GetComponent <MeshRenderer>();
                    HighlighterTool.checkBatchable(list, meshFilter, component);
                }
            }
            if (HighlighterTool.batchableMaterials.Count > 0)
            {
                List <GameObject>[] array = new List <GameObject> [HighlighterTool.batchableMaterials.Count];
                HighlighterTool.batchableMaterials.Values.CopyTo(array, 0);
                for (int k = 0; k < array.Length; k++)
                {
                    if (array[k].Count >= 2)
                    {
                        StaticBatchingUtility.Combine(array[k].ToArray(), Level.roots.gameObject);
                    }
                }
            }
        }
Beispiel #2
0
 public static void addSelection(Transform select)
 {
     HighlighterTool.highlight(select, Color.yellow);
     EditorObjects.selectDecals(select, true);
     EditorObjects.selection.Add(new EditorSelection(select, select.parent, select.position, select.rotation, select.localScale));
     EditorObjects.calculateHandleOffsets();
 }
 // Token: 0x060018F2 RID: 6386 RVA: 0x0008BB44 File Offset: 0x00089F44
 public void applyVisual()
 {
     if (this.isSkinned != this.wasSkinned)
     {
         this.wasSkinned = this.isSkinned;
         if (this.tempSightMaterial != null)
         {
             HighlighterTool.rematerialize(this.sightModel, this.tempSightMaterial, out this.tempSightMaterial);
         }
         if (this.tempTacticalMaterial != null)
         {
             HighlighterTool.rematerialize(this.tacticalModel, this.tempTacticalMaterial, out this.tempTacticalMaterial);
         }
         if (this.tempGripMaterial != null)
         {
             HighlighterTool.rematerialize(this.gripModel, this.tempGripMaterial, out this.tempGripMaterial);
         }
         if (this.tempBarrelMaterial != null)
         {
             HighlighterTool.rematerialize(this.barrelModel, this.tempBarrelMaterial, out this.tempBarrelMaterial);
         }
         if (this.tempMagazineMaterial != null)
         {
             HighlighterTool.rematerialize(this.magazineModel, this.tempMagazineMaterial, out this.tempMagazineMaterial);
         }
     }
 }
Beispiel #4
0
 public override void updateState(Asset asset, byte[] state)
 {
     this._isLit   = (state[0] == 1);
     this.material = HighlighterTool.getMaterialInstance(base.transform);
     this.fire     = base.transform.FindChild("Fire");
     LightLODTool.applyLightLOD(this.fire);
     this.updateFire();
 }
Beispiel #5
0
 private static void checkBatchable(List <GameObject> list, MeshFilter mesh, MeshRenderer renderer)
 {
     if (mesh != null && mesh.sharedMesh != null && renderer != null && renderer.sharedMaterials != null && renderer.sharedMaterials.Length == 1)
     {
         Texture2D texture2D = (Texture2D)renderer.sharedMaterial.mainTexture;
         HighlighterShaderGroup highlighterShaderGroup = null;
         if (texture2D != null && texture2D.wrapMode == 1 && texture2D.width <= 128 && texture2D.height <= 128)
         {
             if (renderer.sharedMaterial.shader.name == "Standard")
             {
                 if (renderer.sharedMaterial.GetFloat("_Mode") == 0f && texture2D.filterMode == null)
                 {
                     highlighterShaderGroup = HighlighterTool.batchableOpaque;
                 }
             }
             else if (renderer.sharedMaterial.shader.name == "Custom/Card")
             {
                 highlighterShaderGroup = HighlighterTool.batchableCard;
             }
             else if (renderer.sharedMaterial.shader.name == "Custom/Foliage" && texture2D.filterMode == 2)
             {
                 highlighterShaderGroup = HighlighterTool.batchableFoliage;
             }
         }
         if (highlighterShaderGroup != null)
         {
             HighlighterBatch highlighterBatch = null;
             if (!highlighterShaderGroup.batchableTextures.TryGetValue(texture2D, out highlighterBatch))
             {
                 highlighterBatch         = HighlighterTool.getBatchable();
                 highlighterBatch.texture = texture2D;
                 highlighterShaderGroup.batchableTextures.Add(texture2D, highlighterBatch);
             }
             if (highlighterBatch != null)
             {
                 List <MeshFilter> list2;
                 if (!highlighterBatch.meshes.TryGetValue(mesh.sharedMesh, out list2))
                 {
                     list2 = new List <MeshFilter>();
                     highlighterBatch.meshes.Add(mesh.sharedMesh, list2);
                 }
                 list2.Add(mesh);
                 highlighterBatch.renderers.Add(renderer);
                 list.Add(mesh.gameObject);
             }
         }
         else
         {
             List <GameObject> list3 = null;
             if (!HighlighterTool.batchableMaterials.TryGetValue(renderer.sharedMaterial, out list3))
             {
                 list3 = new List <GameObject>();
                 HighlighterTool.batchableMaterials.Add(renderer.sharedMaterial, list3);
             }
             list3.Add(mesh.gameObject);
         }
     }
 }
 protected void Start()
 {
     this.material = HighlighterTool.getMaterialInstance(base.transform);
     if (this.material != null)
     {
         LevelLighting.isSeaChanged += this.handleIsSeaChanged;
         this.updateRenderQueue();
     }
 }
Beispiel #7
0
 public override void updateState(Asset asset, byte[] state)
 {
     base.updateState(asset, state);
     this._isPowered = (state[0] == 1);
     if (!Dedicator.isDedicated)
     {
         this.material = HighlighterTool.getMaterialInstance(base.transform);
         this.spot     = base.transform.FindChild("Spots");
         LightLODTool.applyLightLOD(this.spot);
     }
 }
Beispiel #8
0
        public static Transform getItem(ushort id, ushort skin, byte quality, byte[] state, bool viewmodel, ItemAsset itemAsset, SkinAsset skinAsset, out Material tempMaterial)
        {
            tempMaterial = null;
            if (itemAsset != null && itemAsset.item != null)
            {
                if (id != itemAsset.id)
                {
                    Debug.LogError("ID and asset ID are not in sync!");
                }
                Transform transform = Object.Instantiate <GameObject>(itemAsset.item).transform;
                transform.name = id.ToString();
                if (viewmodel)
                {
                    Layerer.viewmodel(transform);
                }
                if (skinAsset != null && skinAsset.primarySkin != null)
                {
                    if (skinAsset.isPattern)
                    {
                        Material material = Object.Instantiate <Material>(skinAsset.primarySkin);
                        material.SetTexture("_AlbedoBase", itemAsset.albedoBase);
                        material.SetTexture("_MetallicBase", itemAsset.metallicBase);
                        material.SetTexture("_EmissionBase", itemAsset.emissionBase);
                        HighlighterTool.rematerialize(transform, material, out tempMaterial);
                    }
                    else
                    {
                        HighlighterTool.rematerialize(transform, skinAsset.primarySkin, out tempMaterial);
                    }
                }
                if (itemAsset.type == EItemType.GUN)
                {
                    Attachments attachments = transform.gameObject.AddComponent <Attachments>();
                    attachments.isSkinned = true;
                    attachments.updateGun((ItemGunAsset)itemAsset, skinAsset);
                    attachments.updateAttachments(state, viewmodel);
                }
                return(transform);
            }
            Transform transform2 = new GameObject().transform;

            transform2.name = id.ToString();
            if (viewmodel)
            {
                transform2.tag = "Viewmodel";
                transform2.gameObject.layer = LayerMasks.VIEWMODEL;
            }
            else
            {
                transform2.tag = "Item";
                transform2.gameObject.layer = LayerMasks.ITEM;
            }
            return(transform2);
        }
        // Token: 0x0600214E RID: 8526 RVA: 0x000B57D0 File Offset: 0x000B3BD0
        private void initToggleGameObject()
        {
            Transform transform = base.transform.FindChildRecursive("Toggle");

            LightLODTool.applyLightLOD(transform);
            if (transform != null)
            {
                this.material         = HighlighterTool.getMaterialInstance(transform.parent);
                this.toggleGameObject = transform.gameObject;
            }
        }
 // Token: 0x06002EAC RID: 11948 RVA: 0x00130304 File Offset: 0x0012E704
 private void clearSelection()
 {
     for (int i = 0; i < this.selection.Count; i++)
     {
         if (this.selection[i].transform != null)
         {
             HighlighterTool.unhighlight(this.selection[i].transform);
             this.selection[i].transform.parent = this.selection[i].parent;
         }
     }
     this.selection.Clear();
     this.calculateHandleOffsets();
 }
Beispiel #11
0
 public static void endBatch()
 {
     HighlighterTool.batch(HighlighterTool.batchableOpaque);
     HighlighterTool.batch(HighlighterTool.batchableCard);
     HighlighterTool.batch(HighlighterTool.batchableFoliage);
     for (int i = 0; i < HighlighterTool.batchableGameObjects.Count; i++)
     {
         if (HighlighterTool.batchableGameObjects[i].Count != 0)
         {
             StaticBatchingUtility.Combine(HighlighterTool.batchableGameObjects[i].ToArray(), Level.roots.gameObject);
         }
     }
 }
 // Token: 0x06002EAB RID: 11947 RVA: 0x00130278 File Offset: 0x0012E678
 public void removeSelection(Transform select)
 {
     for (int i = 0; i < this.selection.Count; i++)
     {
         if (this.selection[i].transform == select)
         {
             HighlighterTool.unhighlight(select);
             this.selection[i].transform.parent = this.selection[i].parent;
             this.selection.RemoveAt(i);
             break;
         }
     }
     this.calculateHandleOffsets();
 }
 // Token: 0x06002610 RID: 9744 RVA: 0x000DF73C File Offset: 0x000DDB3C
 private void Awake()
 {
     this.material = HighlighterTool.getMaterialInstance(base.transform);
     if (Level.isEditor)
     {
         this.onDayNightUpdated(false);
         return;
     }
     if (!this.isListeningLoad)
     {
         this.isListeningLoad = true;
         Level.onLevelLoaded  = (LevelLoaded)Delegate.Combine(Level.onLevelLoaded, new LevelLoaded(this.onLevelLoaded));
     }
 }
Beispiel #14
0
 private void Awake()
 {
     this.material = HighlighterTool.getMaterialInstance(base.transform);
     if (Level.isEditor)
     {
         this.onDayNightUpdated(false);
         return;
     }
     this.onDayNightUpdated(LightingManager.isDaytime);
     if (this.isListening)
     {
         return;
     }
     this.isListening = true;
     LightingManager.onDayNightUpdated = (DayNightUpdated)Delegate.Combine(LightingManager.onDayNightUpdated, new DayNightUpdated(this.onDayNightUpdated));
 }
Beispiel #15
0
 private static void clearSelection()
 {
     for (int i = 0; i < EditorObjects.selection.Count; i++)
     {
         if (EditorObjects.selection[i].transform != null)
         {
             HighlighterTool.unhighlight(EditorObjects.selection[i].transform);
             EditorObjects.selectDecals(EditorObjects.selection[i].transform, false);
             EditorObjects.selection[i].transform.parent = EditorObjects.selection[i].parent;
             if (EditorObjects.selection[i].transform.CompareTag("Barricade") || EditorObjects.selection[i].transform.CompareTag("Structure"))
             {
                 EditorObjects.selection[i].transform.localScale = Vector3.one;
             }
         }
     }
     EditorObjects.selection.Clear();
     EditorObjects.calculateHandleOffsets();
 }
Beispiel #16
0
 public static void removeSelection(Transform select)
 {
     for (int i = 0; i < EditorObjects.selection.Count; i++)
     {
         if (EditorObjects.selection[i].transform == select)
         {
             HighlighterTool.unhighlight(select);
             EditorObjects.selectDecals(select, false);
             EditorObjects.selection[i].transform.parent = EditorObjects.selection[i].parent;
             if (EditorObjects.selection[i].transform.CompareTag("Barricade") || EditorObjects.selection[i].transform.CompareTag("Structure"))
             {
                 EditorObjects.selection[i].transform.localScale = Vector3.one;
             }
             EditorObjects.selection.RemoveAt(i);
             break;
         }
     }
     EditorObjects.calculateHandleOffsets();
 }
Beispiel #17
0
 public override void tick()
 {
     if (this.isConstructing && this.isConstructable)
     {
         this.isConstructing = false;
         if (!Dedicator.isDedicated)
         {
             base.player.playSound(((ItemStructureAsset)base.player.equipment.asset).use);
         }
         if (Provider.isServer)
         {
             AlertTool.alert(base.transform.position, 8f);
         }
     }
     if (base.channel.isOwner)
     {
         if (this.help == null)
         {
             return;
         }
         if (this.isUsing)
         {
             return;
         }
         if (this.check())
         {
             if (!this.isValid)
             {
                 this.isValid = true;
                 HighlighterTool.help(this.help, this.isValid);
             }
         }
         else if (this.isValid)
         {
             this.isValid = false;
             HighlighterTool.help(this.help, this.isValid);
         }
         this.offset        = Mathf.Lerp(this.offset, (float)(this.rotate * 90), 8f * Time.deltaTime);
         this.help.position = this.point;
         this.help.rotation = Quaternion.Euler(-90f, this.angle + this.offset, 0f);
     }
 }
Beispiel #18
0
 public override void equip()
 {
     base.player.animator.play("Equip", true);
     this.useTime = base.player.animator.getAnimationLength("Use");
     if (Dedicator.isDedicated)
     {
         GameObject gameObject = Object.Instantiate <GameObject>(((ItemStructureAsset)base.player.equipment.asset).clip, Vector3.zero, Quaternion.identity);
         gameObject.name = "Helper";
         Collider component = gameObject.GetComponent <Collider>();
         if (component != null)
         {
             this.boundsUse     = true;
             this.boundsCenter  = gameObject.transform.InverseTransformPoint(component.bounds.center);
             this.boundsExtents = component.bounds.extents;
         }
         Object.Destroy(gameObject);
         this.boundsOverlap = this.boundsExtents + new Vector3(0.1f, 0.1f, 0.1f);
     }
     if (base.channel.isOwner)
     {
         this.help          = StructureTool.getStructure(base.player.equipment.itemID, 0);
         this.help.position = Vector3.zero;
         this.help.rotation = Quaternion.identity;
         Collider component2 = this.help.GetComponent <Collider>();
         if (component2 != null)
         {
             this.boundsUse     = true;
             this.boundsCenter  = this.help.InverseTransformPoint(component2.bounds.center);
             this.boundsExtents = component2.bounds.extents;
             Object.Destroy(component2);
         }
         this.boundsOverlap = this.boundsExtents + new Vector3(0.1f, 0.1f, 0.1f);
         this.help.rotation = Quaternion.Euler(-90f, 0f, 0f);
         HighlighterTool.help(this.help, this.isValid);
         if (this.help.FindChild("Clip") != null)
         {
             Object.Destroy(this.help.FindChild("Clip").gameObject);
         }
         if (this.help.FindChild("Nav") != null)
         {
             Object.Destroy(this.help.FindChild("Nav").gameObject);
         }
         if (this.help.FindChild("Cutter") != null)
         {
             Object.Destroy(this.help.FindChild("Cutter").gameObject);
         }
         if (this.help.FindChild("Roof") != null)
         {
             Object.Destroy(this.help.FindChild("Roof").gameObject);
         }
         if (this.help.FindChild("Block") != null)
         {
             Object.Destroy(this.help.FindChild("Block").gameObject);
         }
         for (int i = 0; i < 4; i++)
         {
             if (!(this.help.FindChild("Wall") != null))
             {
                 break;
             }
             Object.Destroy(this.help.FindChild("Wall").gameObject);
         }
         for (int j = 0; j < 4; j++)
         {
             if (!(this.help.FindChild("Pillar") != null))
             {
                 break;
             }
             Object.Destroy(this.help.FindChild("Pillar").gameObject);
         }
     }
 }
Beispiel #19
0
 private void Awake()
 {
     this.material      = HighlighterTool.getMaterialInstance(base.transform);
     this.blackoutTime  = Time.time;
     this.blackoutDelay = Random.Range(0f, 13.2f);
 }
Beispiel #20
0
 public static void help(Transform target, bool isValid)
 {
     HighlighterTool.help(target, isValid, false);
 }
        // Token: 0x06003424 RID: 13348 RVA: 0x00153C00 File Offset: 0x00152000
        public static Transform getItem(ushort id, ushort skin, byte quality, byte[] state, bool viewmodel, ItemAsset itemAsset, SkinAsset skinAsset, List <Mesh> outTempMeshes, out Material tempMaterial, GetStatTrackerValueHandler statTrackerCallback)
        {
            tempMaterial = null;
            if (itemAsset != null && itemAsset.item != null)
            {
                if (id != itemAsset.id)
                {
                    Debug.LogError("ID and asset ID are not in sync!");
                }
                Transform transform = UnityEngine.Object.Instantiate <GameObject>(itemAsset.item).transform;
                transform.name = id.ToString();
                if (viewmodel)
                {
                    Layerer.viewmodel(transform);
                }
                if (skinAsset != null)
                {
                    if (skinAsset.overrideMeshes != null && skinAsset.overrideMeshes.Count > 0)
                    {
                        HighlighterTool.remesh(transform, skinAsset.overrideMeshes, outTempMeshes, true);
                    }
                    else if (outTempMeshes != null)
                    {
                        outTempMeshes.Clear();
                    }
                    if (skinAsset.primarySkin != null)
                    {
                        if (skinAsset.isPattern)
                        {
                            Material material = UnityEngine.Object.Instantiate <Material>(skinAsset.primarySkin);
                            material.SetTexture("_AlbedoBase", itemAsset.albedoBase);
                            material.SetTexture("_MetallicBase", itemAsset.metallicBase);
                            material.SetTexture("_EmissionBase", itemAsset.emissionBase);
                            HighlighterTool.rematerialize(transform, material, out tempMaterial);
                        }
                        else
                        {
                            HighlighterTool.rematerialize(transform, skinAsset.primarySkin, out tempMaterial);
                        }
                    }
                }
                else if (outTempMeshes != null)
                {
                    outTempMeshes.Clear();
                }
                if (itemAsset.type == EItemType.GUN)
                {
                    Attachments attachments = transform.gameObject.AddComponent <Attachments>();
                    attachments.isSkinned = true;
                    attachments.updateGun((ItemGunAsset)itemAsset, skinAsset);
                    attachments.updateAttachments(state, viewmodel);
                }
                EStatTrackerType estatTrackerType;
                int num;
                if (!Dedicator.isDedicated && statTrackerCallback != null && statTrackerCallback(out estatTrackerType, out num))
                {
                    StatTracker statTracker = transform.gameObject.AddComponent <StatTracker>();
                    statTracker.statTrackerCallback = statTrackerCallback;
                    statTracker.updateStatTracker(viewmodel);
                }
                return(transform);
            }
            Transform transform2 = new GameObject().transform;

            transform2.name = id.ToString();
            if (viewmodel)
            {
                transform2.tag = "Viewmodel";
                transform2.gameObject.layer = LayerMasks.VIEWMODEL;
            }
            else
            {
                transform2.tag = "Item";
                transform2.gameObject.layer = LayerMasks.ITEM;
            }
            return(transform2);
        }
 // Token: 0x06002EAA RID: 11946 RVA: 0x0013024D File Offset: 0x0012E64D
 public void addSelection(Transform select)
 {
     HighlighterTool.highlight(select, Color.yellow);
     this.selection.Add(new WorkzoneSelection(select, select.parent));
     this.calculateHandleOffsets();
 }
 // Token: 0x060018F4 RID: 6388 RVA: 0x0008BC48 File Offset: 0x0008A048
 public void updateAttachments(byte[] state, bool viewmodel)
 {
     if (state == null || state.Length != 18)
     {
         return;
     }
     base.transform.localScale = Vector3.one;
     this._sightID             = BitConverter.ToUInt16(state, 0);
     this._tacticalID          = BitConverter.ToUInt16(state, 2);
     this._gripID     = BitConverter.ToUInt16(state, 4);
     this._barrelID   = BitConverter.ToUInt16(state, 6);
     this._magazineID = BitConverter.ToUInt16(state, 8);
     if (this.sightModel != null)
     {
         UnityEngine.Object.Destroy(this.sightModel.gameObject);
         this._sightModel = null;
     }
     try
     {
         this._sightAsset = (ItemSightAsset)Assets.find(EAssetType.ITEM, this.sightID);
     }
     catch
     {
         this._sightAsset = null;
     }
     this.tempSightMaterial = null;
     if (this.sightAsset != null && this.sightHook != null)
     {
         this._sightModel                        = UnityEngine.Object.Instantiate <GameObject>(this.sightAsset.sight).transform;
         this.sightModel.name                    = "Sight";
         this.sightModel.transform.parent        = this.sightHook;
         this.sightModel.transform.localPosition = Vector3.zero;
         this.sightModel.transform.localRotation = Quaternion.identity;
         this.sightModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.sightModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.sightID, out material) && this.skinAsset.hasSight && this.sightAsset.isPaintable)
             {
                 if (this.sightAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material.SetTexture("_AlbedoBase", this.sightAsset.albedoBase);
                     material.SetTexture("_MetallicBase", this.sightAsset.metallicBase);
                     material.SetTexture("_EmissionBase", this.sightAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material = this.skinAsset.tertiarySkin;
                 }
             }
             if (material != null)
             {
                 HighlighterTool.rematerialize(this.sightModel, material, out this.tempSightMaterial);
             }
         }
     }
     if (this.tacticalModel != null)
     {
         UnityEngine.Object.Destroy(this.tacticalModel.gameObject);
         this._tacticalModel = null;
     }
     try
     {
         this._tacticalAsset = (ItemTacticalAsset)Assets.find(EAssetType.ITEM, this.tacticalID);
     }
     catch
     {
         this._tacticalAsset = null;
     }
     this.tempTacticalMaterial = null;
     if (this.tacticalAsset != null && this.tacticalHook != null)
     {
         this._tacticalModel                        = UnityEngine.Object.Instantiate <GameObject>(this.tacticalAsset.tactical).transform;
         this.tacticalModel.name                    = "Tactical";
         this.tacticalModel.transform.parent        = this.tacticalHook;
         this.tacticalModel.transform.localPosition = Vector3.zero;
         this.tacticalModel.transform.localRotation = Quaternion.identity;
         this.tacticalModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.tacticalModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material2 = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.tacticalID, out material2) && this.skinAsset.hasTactical && this.tacticalAsset.isPaintable)
             {
                 if (this.tacticalAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material2 = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material2.SetTexture("_AlbedoBase", this.tacticalAsset.albedoBase);
                     material2.SetTexture("_MetallicBase", this.tacticalAsset.metallicBase);
                     material2.SetTexture("_EmissionBase", this.tacticalAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material2 = this.skinAsset.tertiarySkin;
                 }
             }
             if (material2 != null)
             {
                 HighlighterTool.rematerialize(this.tacticalModel, material2, out this.tempTacticalMaterial);
             }
         }
     }
     if (this.gripModel != null)
     {
         UnityEngine.Object.Destroy(this.gripModel.gameObject);
         this._gripModel = null;
     }
     try
     {
         this._gripAsset = (ItemGripAsset)Assets.find(EAssetType.ITEM, this.gripID);
     }
     catch
     {
         this._gripAsset = null;
     }
     this.tempGripMaterial = null;
     if (this.gripAsset != null && this.gripHook != null)
     {
         this._gripModel                        = UnityEngine.Object.Instantiate <GameObject>(this.gripAsset.grip).transform;
         this.gripModel.name                    = "Grip";
         this.gripModel.transform.parent        = this.gripHook;
         this.gripModel.transform.localPosition = Vector3.zero;
         this.gripModel.transform.localRotation = Quaternion.identity;
         this.gripModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.gripModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material3 = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.gripID, out material3) && this.skinAsset.hasGrip && this.gripAsset.isPaintable)
             {
                 if (this.gripAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material3 = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material3.SetTexture("_AlbedoBase", this.gripAsset.albedoBase);
                     material3.SetTexture("_MetallicBase", this.gripAsset.metallicBase);
                     material3.SetTexture("_EmissionBase", this.gripAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material3 = this.skinAsset.tertiarySkin;
                 }
             }
             if (material3 != null)
             {
                 HighlighterTool.rematerialize(this.gripModel, material3, out this.tempGripMaterial);
             }
         }
     }
     if (this.barrelModel != null)
     {
         UnityEngine.Object.Destroy(this.barrelModel.gameObject);
         this._barrelModel = null;
     }
     try
     {
         this._barrelAsset = (ItemBarrelAsset)Assets.find(EAssetType.ITEM, this.barrelID);
     }
     catch
     {
         this._barrelAsset = null;
     }
     this.tempBarrelMaterial = null;
     if (this.barrelAsset != null && this.barrelHook != null)
     {
         this._barrelModel                        = UnityEngine.Object.Instantiate <GameObject>(this.barrelAsset.barrel).transform;
         this.barrelModel.name                    = "Barrel";
         this.barrelModel.transform.parent        = this.barrelHook;
         this.barrelModel.transform.localPosition = Vector3.zero;
         this.barrelModel.transform.localRotation = Quaternion.identity;
         this.barrelModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.barrelModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material4 = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.barrelID, out material4) && this.skinAsset.hasBarrel && this.barrelAsset.isPaintable)
             {
                 if (this.barrelAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material4 = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material4.SetTexture("_AlbedoBase", this.barrelAsset.albedoBase);
                     material4.SetTexture("_MetallicBase", this.barrelAsset.metallicBase);
                     material4.SetTexture("_EmissionBase", this.barrelAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material4 = this.skinAsset.tertiarySkin;
                 }
             }
             if (material4 != null)
             {
                 HighlighterTool.rematerialize(this.barrelModel, material4, out this.tempBarrelMaterial);
             }
         }
     }
     if (this.magazineModel != null)
     {
         UnityEngine.Object.Destroy(this.magazineModel.gameObject);
         this._magazineModel = null;
     }
     try
     {
         this._magazineAsset = (ItemMagazineAsset)Assets.find(EAssetType.ITEM, this.magazineID);
     }
     catch
     {
         this._magazineAsset = null;
     }
     this.tempMagazineMaterial = null;
     if (this.magazineAsset != null && this.magazineHook != null)
     {
         Transform transform = null;
         if (this.magazineAsset.calibers.Length > 0)
         {
             transform = this.magazineHook.FindChild("Caliber_" + this.magazineAsset.calibers[0]);
         }
         if (transform == null)
         {
             transform = this.magazineHook;
         }
         this._magazineModel                        = UnityEngine.Object.Instantiate <GameObject>(this.magazineAsset.magazine).transform;
         this.magazineModel.name                    = "Magazine";
         this.magazineModel.transform.parent        = transform;
         this.magazineModel.transform.localPosition = Vector3.zero;
         this.magazineModel.transform.localRotation = Quaternion.identity;
         this.magazineModel.localScale              = Vector3.one;
         if (viewmodel)
         {
             Layerer.viewmodel(this.magazineModel);
         }
         if (this.gunAsset != null && this.skinAsset != null && this.skinAsset.secondarySkins != null)
         {
             Material material5 = null;
             if (!this.skinAsset.secondarySkins.TryGetValue(this.magazineID, out material5) && this.skinAsset.hasMagazine && this.magazineAsset.isPaintable)
             {
                 if (this.magazineAsset.albedoBase != null && this.skinAsset.attachmentSkin != null)
                 {
                     material5 = UnityEngine.Object.Instantiate <Material>(this.skinAsset.attachmentSkin);
                     material5.SetTexture("_AlbedoBase", this.magazineAsset.albedoBase);
                     material5.SetTexture("_MetallicBase", this.magazineAsset.metallicBase);
                     material5.SetTexture("_EmissionBase", this.magazineAsset.emissionBase);
                 }
                 else if (this.skinAsset.tertiarySkin != null)
                 {
                     material5 = this.skinAsset.tertiarySkin;
                 }
             }
             if (material5 != null)
             {
                 HighlighterTool.rematerialize(this.magazineModel, material5, out this.tempMagazineMaterial);
             }
         }
     }
     if (this.tacticalModel != null && this.tacticalModel.childCount > 0)
     {
         this._lightHook  = this.tacticalModel.transform.FindChild("Model_0").FindChild("Light");
         this._light2Hook = this.tacticalModel.transform.FindChild("Model_0").FindChild("Light2");
         if (viewmodel)
         {
             if (this.lightHook != null)
             {
                 this.lightHook.tag = "Viewmodel";
                 this.lightHook.gameObject.layer = LayerMasks.VIEWMODEL;
                 Transform transform2 = this.lightHook.FindChild("Light");
                 if (transform2 != null)
                 {
                     transform2.tag = "Viewmodel";
                     transform2.gameObject.layer = LayerMasks.VIEWMODEL;
                 }
             }
             if (this.light2Hook != null)
             {
                 this.light2Hook.tag = "Viewmodel";
                 this.light2Hook.gameObject.layer = LayerMasks.VIEWMODEL;
                 Transform transform3 = this.light2Hook.FindChild("Light");
                 if (transform3 != null)
                 {
                     transform3.tag = "Viewmodel";
                     transform3.gameObject.layer = LayerMasks.VIEWMODEL;
                 }
             }
         }
         else
         {
             LightLODTool.applyLightLOD(this.lightHook);
             LightLODTool.applyLightLOD(this.light2Hook);
         }
     }
     else
     {
         this._lightHook  = null;
         this._light2Hook = null;
     }
     if (this.sightModel != null)
     {
         this._aimHook = this.sightModel.transform.FindChild("Model_0").FindChild("Aim");
         if (this.aimHook != null)
         {
             Transform transform4 = this.aimHook.parent.FindChild("Reticule");
             if (transform4 != null)
             {
                 Renderer component = transform4.GetComponent <Renderer>();
                 Material material6 = component.material;
                 material6.SetColor("_Color", OptionsSettings.criticalHitmarkerColor);
                 material6.SetColor("_EmissionColor", OptionsSettings.criticalHitmarkerColor);
             }
         }
         this._reticuleHook = this.sightModel.transform.FindChild("Model_0").FindChild("Reticule");
     }
     else
     {
         this._aimHook      = null;
         this._reticuleHook = null;
     }
     if (this.aimHook != null)
     {
         this._scopeHook = this.aimHook.FindChild("Scope");
     }
     else
     {
         this._scopeHook = null;
     }
     if (this.rope != null && viewmodel)
     {
         this.rope.tag = "Viewmodel";
         this.rope.gameObject.layer = LayerMasks.VIEWMODEL;
     }
     this.wasSkinned = true;
     this.applyVisual();
 }
Beispiel #24
0
 // Token: 0x06002C0E RID: 11278 RVA: 0x00117EA4 File Offset: 0x001162A4
 private void Update()
 {
     if (base.channel.isOwner)
     {
         if (base.player.stance.stance != EPlayerStance.DRIVING && base.player.stance.stance != EPlayerStance.SITTING && !base.player.life.isDead && !base.player.workzone.isBuilding)
         {
             if (Time.realtimeSinceStartup - PlayerInteract.lastInteract > 0.1f)
             {
                 PlayerInteract.lastInteract = Time.realtimeSinceStartup;
                 if (base.player.look.isCam)
                 {
                     PhysicsUtility.raycast(new Ray(base.player.look.aim.position, base.player.look.aim.forward), out PlayerInteract.hit, 4f, RayMasks.PLAYER_INTERACT, QueryTriggerInteraction.UseGlobal);
                 }
                 else
                 {
                     PhysicsUtility.raycast(new Ray(MainCamera.instance.transform.position, MainCamera.instance.transform.forward), out PlayerInteract.hit, (float)((base.player.look.perspective != EPlayerPerspective.THIRD) ? 4 : 6), RayMasks.PLAYER_INTERACT, QueryTriggerInteraction.UseGlobal);
                 }
             }
             if (PlayerInteract.hit.transform != PlayerInteract.focus)
             {
                 if (PlayerInteract.focus != null && PlayerInteract.interactable != null)
                 {
                     InteractableDoorHinge component = PlayerInteract.focus.GetComponent <InteractableDoorHinge>();
                     if (component != null)
                     {
                         HighlighterTool.unhighlight(PlayerInteract.focus.parent.parent);
                     }
                     else
                     {
                         HighlighterTool.unhighlight(PlayerInteract.focus);
                     }
                 }
                 PlayerInteract.focus          = null;
                 PlayerInteract.target         = null;
                 PlayerInteract._interactable  = null;
                 PlayerInteract._interactable2 = null;
                 if (PlayerInteract.hit.transform != null)
                 {
                     PlayerInteract.focus          = PlayerInteract.hit.transform;
                     PlayerInteract._interactable  = PlayerInteract.focus.GetComponent <Interactable>();
                     PlayerInteract._interactable2 = PlayerInteract.focus.GetComponent <Interactable2>();
                     if (PlayerInteract.interactable != null)
                     {
                         PlayerInteract.target = PlayerInteract.focus.FindChildRecursive("Target");
                         if (PlayerInteract.interactable.checkInteractable())
                         {
                             if (PlayerUI.window.isEnabled)
                             {
                                 if (PlayerInteract.interactable.checkUseable())
                                 {
                                     Color color;
                                     if (!PlayerInteract.interactable.checkHighlight(out color))
                                     {
                                         color = Color.green;
                                     }
                                     InteractableDoorHinge component2 = PlayerInteract.focus.GetComponent <InteractableDoorHinge>();
                                     if (component2 != null)
                                     {
                                         HighlighterTool.highlight(PlayerInteract.focus.parent.parent, color);
                                     }
                                     else
                                     {
                                         HighlighterTool.highlight(PlayerInteract.focus, color);
                                     }
                                 }
                                 else
                                 {
                                     Color color = Color.red;
                                     InteractableDoorHinge component3 = PlayerInteract.focus.GetComponent <InteractableDoorHinge>();
                                     if (component3 != null)
                                     {
                                         HighlighterTool.highlight(PlayerInteract.focus.parent.parent, color);
                                     }
                                     else
                                     {
                                         HighlighterTool.highlight(PlayerInteract.focus, color);
                                     }
                                 }
                             }
                         }
                         else
                         {
                             PlayerInteract.target        = null;
                             PlayerInteract._interactable = null;
                         }
                     }
                 }
             }
         }
         else
         {
             if (PlayerInteract.focus != null && PlayerInteract.interactable != null)
             {
                 InteractableDoorHinge component4 = PlayerInteract.focus.GetComponent <InteractableDoorHinge>();
                 if (component4 != null)
                 {
                     HighlighterTool.unhighlight(PlayerInteract.focus.parent.parent);
                 }
                 else
                 {
                     HighlighterTool.unhighlight(PlayerInteract.focus);
                 }
             }
             PlayerInteract.focus          = null;
             PlayerInteract.target         = null;
             PlayerInteract._interactable  = null;
             PlayerInteract._interactable2 = null;
         }
     }
     if (base.channel.isOwner && !base.player.life.isDead)
     {
         if (PlayerInteract.interactable != null)
         {
             EPlayerMessage message;
             string         text;
             Color          color2;
             if (PlayerInteract.interactable.checkHint(out message, out text, out color2) && !PlayerUI.window.showCursor)
             {
                 if (PlayerInteract.interactable.CompareTag("Item"))
                 {
                     PlayerUI.hint((!(PlayerInteract.target != null)) ? PlayerInteract.focus : PlayerInteract.target, message, text, color2, new object[]
                     {
                         ((InteractableItem)PlayerInteract.interactable).item,
                         ((InteractableItem)PlayerInteract.interactable).asset
                     });
                 }
                 else
                 {
                     PlayerUI.hint((!(PlayerInteract.target != null)) ? PlayerInteract.focus : PlayerInteract.target, message, text, color2, new object[0]);
                 }
             }
         }
         else if (PlayerInteract.purchaseAsset != null && base.player.movement.purchaseNode != null && !PlayerUI.window.showCursor)
         {
             PlayerUI.hint(null, EPlayerMessage.PURCHASE, string.Empty, Color.white, new object[]
             {
                 PlayerInteract.purchaseAsset.itemName,
                 base.player.movement.purchaseNode.cost
             });
         }
         else if (PlayerInteract.focus != null && PlayerInteract.focus.CompareTag("Enemy"))
         {
             Player player = DamageTool.getPlayer(PlayerInteract.focus);
             if (player != null && player != Player.player && !PlayerUI.window.showCursor)
             {
                 PlayerUI.hint(null, EPlayerMessage.ENEMY, string.Empty, Color.white, new object[]
                 {
                     player.channel.owner
                 });
             }
         }
         EPlayerMessage message2;
         float          data;
         if (PlayerInteract.interactable2 != null && PlayerInteract.interactable2.checkHint(out message2, out data) && !PlayerUI.window.showCursor)
         {
             PlayerUI.hint2(message2, (!PlayerInteract.isHoldingKey) ? 0f : ((Time.realtimeSinceStartup - PlayerInteract.lastKeyDown) / this.salvageTime), data);
         }
         if ((base.player.stance.stance == EPlayerStance.DRIVING || base.player.stance.stance == EPlayerStance.SITTING) && !Input.GetKey(KeyCode.LeftShift))
         {
             if (Input.GetKeyDown(KeyCode.F1))
             {
                 this.hotkey(0);
             }
             if (Input.GetKeyDown(KeyCode.F2))
             {
                 this.hotkey(1);
             }
             if (Input.GetKeyDown(KeyCode.F3))
             {
                 this.hotkey(2);
             }
             if (Input.GetKeyDown(KeyCode.F4))
             {
                 this.hotkey(3);
             }
             if (Input.GetKeyDown(KeyCode.F5))
             {
                 this.hotkey(4);
             }
             if (Input.GetKeyDown(KeyCode.F6))
             {
                 this.hotkey(5);
             }
             if (Input.GetKeyDown(KeyCode.F7))
             {
                 this.hotkey(6);
             }
             if (Input.GetKeyDown(KeyCode.F8))
             {
                 this.hotkey(7);
             }
             if (Input.GetKeyDown(KeyCode.F9))
             {
                 this.hotkey(8);
             }
             if (Input.GetKeyDown(KeyCode.F10))
             {
                 this.hotkey(9);
             }
         }
         if (Input.GetKeyDown(ControlsSettings.interact))
         {
             PlayerInteract.lastKeyDown  = Time.realtimeSinceStartup;
             PlayerInteract.isHoldingKey = true;
         }
         if (Input.GetKeyDown(ControlsSettings.inspect) && ControlsSettings.inspect != ControlsSettings.interact && base.player.equipment.canInspect)
         {
             base.channel.send("askInspect", ESteamCall.SERVER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[0]);
         }
         if (PlayerInteract.isHoldingKey)
         {
             if (Input.GetKeyUp(ControlsSettings.interact))
             {
                 PlayerInteract.isHoldingKey = false;
                 if (PlayerUI.window.showCursor)
                 {
                     if (base.player.inventory.isStoring && base.player.inventory.shouldInteractCloseStorage)
                     {
                         PlayerDashboardUI.close();
                         PlayerLifeUI.open();
                     }
                     else if (PlayerBarricadeSignUI.active)
                     {
                         PlayerBarricadeSignUI.close();
                         PlayerLifeUI.open();
                     }
                     else if (PlayerBarricadeStereoUI.active)
                     {
                         PlayerBarricadeStereoUI.close();
                         PlayerLifeUI.open();
                     }
                     else if (PlayerBarricadeLibraryUI.active)
                     {
                         PlayerBarricadeLibraryUI.close();
                         PlayerLifeUI.open();
                     }
                     else if (PlayerBarricadeMannequinUI.active)
                     {
                         PlayerBarricadeMannequinUI.close();
                         PlayerLifeUI.open();
                     }
                     else if (PlayerNPCDialogueUI.active)
                     {
                         if (PlayerNPCDialogueUI.dialogueAnimating)
                         {
                             PlayerNPCDialogueUI.skipText();
                         }
                         else if (PlayerNPCDialogueUI.dialogueHasNextPage)
                         {
                             PlayerNPCDialogueUI.nextPage();
                         }
                         else
                         {
                             PlayerNPCDialogueUI.close();
                             PlayerLifeUI.open();
                         }
                     }
                     else if (PlayerNPCQuestUI.active)
                     {
                         PlayerNPCQuestUI.closeNicely();
                     }
                     else if (PlayerNPCVendorUI.active)
                     {
                         PlayerNPCVendorUI.closeNicely();
                     }
                 }
                 else if (base.player.stance.stance == EPlayerStance.DRIVING || base.player.stance.stance == EPlayerStance.SITTING)
                 {
                     VehicleManager.exitVehicle();
                 }
                 else if (PlayerInteract.focus != null && PlayerInteract.interactable != null)
                 {
                     if (PlayerInteract.interactable.checkUseable())
                     {
                         PlayerInteract.interactable.use();
                     }
                 }
                 else if (PlayerInteract.purchaseAsset != null)
                 {
                     if (base.player.skills.experience >= base.player.movement.purchaseNode.cost)
                     {
                         base.player.skills.sendPurchase(base.player.movement.purchaseNode);
                     }
                 }
                 else if (ControlsSettings.inspect == ControlsSettings.interact && base.player.equipment.canInspect)
                 {
                     base.channel.send("askInspect", ESteamCall.SERVER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[0]);
                 }
             }
             else if (Time.realtimeSinceStartup - PlayerInteract.lastKeyDown > this.salvageTime)
             {
                 PlayerInteract.isHoldingKey = false;
                 if (!PlayerUI.window.showCursor && PlayerInteract.interactable2 != null)
                 {
                     PlayerInteract.interactable2.use();
                 }
             }
         }
     }
 }