public void BuildTank(NodeAddedEvent e, HangarTankBaseSystem.HangarNode hangar, HangarTankBaseSystem.WeaponSkinItemPreviewLoadedNode weaponSkin, [Context, JoinByParentGroup] HangarTankBaseSystem.WeaponItemPreviewNode weaponItem, HangarTankBaseSystem.HullSkinItemPreviewLoadedNode tankSkin, [Context, JoinByParentGroup] HangarTankBaseSystem.TankItemPreviewNode tankItem, TankPaintItemPreviewLoadedNode tankPaint, WeaponPaintItemPreviewLoadedNode weaponPaint, HangarTankBaseSystem.HangarCameraNode hangarCamera, SingleNode <SupplyEffectSettingsComponent> settings)
        {
            Transform root = hangar.hangarTankPosition.transform;

            root.DestroyChildren();
            GameObject tankInstance = (GameObject)Object.Instantiate(tankSkin.resourceData.Data);

            tankInstance.transform.SetParent(root);
            tankInstance.transform.localPosition = Vector3.zero;
            tankInstance.transform.localRotation = Quaternion.identity;
            tankSkin.hangarItemPreview.Instance  = tankInstance;
            tankInstance.GetComponentInChildren <NitroEffectComponent>().InitEffect(settings.component);
            Transform  mountPoint     = tankInstance.GetComponent <MountPointComponent>().MountPoint;
            GameObject weaponInstance = (GameObject)Object.Instantiate(weaponSkin.resourceData.Data);

            weaponInstance.transform.SetParent(tankInstance.transform);
            weaponInstance.transform.localPosition = mountPoint.localPosition;
            weaponInstance.transform.localRotation = mountPoint.localRotation;
            weaponSkin.hangarItemPreview.Instance  = weaponInstance;
            GameObject tankPaintInstance = (GameObject)Object.Instantiate(tankPaint.resourceData.Data);

            tankPaintInstance.transform.SetParent(tankInstance.transform);
            tankPaintInstance.transform.localPosition = Vector3.zero;
            GameObject weaponPaintInstance = (GameObject)Object.Instantiate(weaponPaint.resourceData.Data);

            weaponPaintInstance.transform.SetParent(tankInstance.transform);
            weaponPaintInstance.transform.localPosition = Vector3.zero;
            PhysicsUtil.SetGameObjectLayer(root.gameObject, Layers.STATIC);
            this.ApplyPaint(tankInstance, weaponInstance, tankPaintInstance, weaponPaintInstance);
            weaponInstance.GetComponentInChildren <DoubleDamageEffectComponent>().InitEffect(settings.component);
            weaponInstance.GetComponentInChildren <DoubleDamageSoundEffectComponent>().RecalculatePlayingParameters();
            Renderer weaponRenderer = TankBuilderUtil.GetWeaponRenderer(weaponInstance);

            weaponRenderer.tag = "TankWeapon";
            Renderer hullRenderer = TankBuilderUtil.GetHullRenderer(tankInstance);

            hullRenderer.tag = "TankHull";
            weaponRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
            weaponRenderer.lightProbeUsage      = LightProbeUsage.Off;
            hullRenderer.reflectionProbeUsage   = ReflectionProbeUsage.Off;
            hullRenderer.lightProbeUsage        = LightProbeUsage.Off;
            BurningTargetBloom componentInChildren = hangarCamera.cameraRootTransform.Root.GetComponentInChildren <BurningTargetBloom>();

            componentInChildren.targets.Clear();
            componentInChildren.targets.Add(weaponRenderer);
            componentInChildren.targets.Add(hullRenderer);
            base.ScheduleEvent <HangarTankBuildedEvent>(hangar);
        }
Example #2
0
        public void OnNodeAdded(NodeAddedEvent evt, HullGraphicsNode hullGraphics)
        {
            Entity     entity       = hullGraphics.Entity;
            GameObject hullInstance = hullGraphics.hullInstance.HullInstance;

            hullInstance.GetComponent <EntityBehaviour>().BuildEntity(entity);
            BaseRendererComponent component = new BaseRendererComponent {
                Renderer = TankBuilderUtil.GetHullRenderer(hullInstance)
            };

            component.Mesh = (component.Renderer as SkinnedMeshRenderer).sharedMesh;
            entity.AddComponent <StartMaterialsComponent>();
            entity.AddComponent(component);
            TrackRendererComponent component3 = new TrackRendererComponent {
                Renderer = component.Renderer
            };

            entity.AddComponent(component3);
            base.ScheduleEvent <ChassisInitEvent>(entity);
        }
 private void ApplyPaint(GameObject tankInstance, GameObject weaponInstance, GameObject tankPaintInstance, GameObject weaponPaintInstance)
 {
     TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetHullRenderer(tankInstance), TankBuilderUtil.GetWeaponRenderer(weaponInstance), tankPaintInstance.GetComponent <ColoringComponent>(), weaponPaintInstance.GetComponent <ColoringComponent>());
 }
Example #4
0
 private void SetColoring(ColoringComponent coloring)
 {
     this.coloring = coloring;
     TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetHullRenderer(this.hullInstance), coloring);
     TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetWeaponRenderer(this.weaponInstance), coloring);
 }