public void Render(ProjectorConfig config)
        {
            if (!config.AssetReady)
            {
                return;
            }
            float value  = config.Outline ? config.OutlineInner : 0f;
            float value2 = config.Outline ? config.OutlineOuter : 0f;

            Renderer[] componentsInChildren = config.MainAsset.GetComponentsInChildren <Renderer>();
            int        i   = 0;
            int        num = componentsInChildren.Length;

            while (i < num)
            {
                Renderer renderer = componentsInChildren[i];
                if (renderer.sharedMaterial != null && renderer.sharedMaterial.HasProperty("_OutlineInnerWidth") && renderer.sharedMaterial.HasProperty("_Outline"))
                {
                    renderer.sharedMaterial.SetFloat("_Outline", value2);
                    renderer.sharedMaterial.SetFloat("_OutlineInnerWidth", value);
                }
                i++;
            }
            this.baseRenderer.Render(config);
        }
예제 #2
0
 public void MakeEquivalentTo(ProjectorConfig config)
 {
     if (config == null)
     {
         return;
     }
     this.AssetName                   = config.AssetName;
     this.AttachmentAssets            = config.AttachmentAssets;
     this.CameraPosition              = config.CameraPosition;
     this.CameraInterest              = config.CameraInterest;
     this.closeup                     = config.closeup;
     this.SnapshotFrameDelay          = config.SnapshotFrameDelay;
     this.AnimPreference              = config.AnimPreference;
     this.AnimationName               = config.AnimationName;
     this.AnimState                   = config.AnimState;
     this.Metered                     = config.Metered;
     this.MeterValue                  = config.MeterValue;
     this.Outline                     = config.Outline;
     this.OutlineOuter                = config.OutlineOuter;
     this.OutlineInner                = config.OutlineInner;
     this.TrackerName                 = config.TrackerName;
     this.FrameSprite                 = config.FrameSprite;
     this.Sharpness                   = config.Sharpness;
     this.RenderWidth                 = config.RenderWidth;
     this.RenderHeight                = config.RenderHeight;
     this.buildingEquipmentShaderName = config.buildingEquipmentShaderName;
     this.Tint = config.Tint;
 }
예제 #3
0
 public bool IsEquivalentTo(ProjectorConfig config)
 {
     if (config == null)
     {
         return(false);
     }
     if (this.AssetName != config.AssetName)
     {
         return(false);
     }
     if (this.AttachmentAssets != null && config.AttachmentAssets != null)
     {
         if (this.AttachmentAssets.Length != config.AttachmentAssets.Length)
         {
             return(false);
         }
         for (int i = 0; i < this.AttachmentAssets.Length; i++)
         {
             if (this.AttachmentAssets[i] != config.AttachmentAssets[i])
             {
                 return(false);
             }
         }
     }
     return(!(this.CameraPosition != config.CameraPosition) && !(this.CameraInterest != config.CameraInterest) && this.closeup == config.closeup && this.SnapshotFrameDelay == config.SnapshotFrameDelay && this.AnimPreference == config.AnimPreference && !(this.AnimationName != config.AnimationName) && this.AnimState == config.AnimState && this.Metered == config.Metered && this.MeterValue == config.MeterValue && this.Outline == config.Outline && this.OutlineOuter == config.OutlineOuter && this.OutlineInner == config.OutlineInner && !(this.TrackerName != config.TrackerName) && this.FrameSprite == config.FrameSprite && this.Sharpness == config.Sharpness && this.RenderWidth == config.RenderWidth && this.RenderHeight == config.RenderHeight && !(this.buildingEquipmentShaderName != config.buildingEquipmentShaderName) && !(this.Tint != config.Tint));
 }
예제 #4
0
 public void Destroy()
 {
     Service.Get <EventManager>().UnregisterObserver(this, EventId.ForceGeometryReload);
     Service.Get <ProjectorManager>().RemoveProjector(this);
     if (this.AssetProcessor != null)
     {
         this.AssetProcessor.UnloadAllAssets(null);
         this.AssetProcessor = null;
     }
     if (this.Renderer != null)
     {
         this.Renderer.Destroy();
         this.Renderer = null;
     }
     if (this.Config != null)
     {
         this.Config.Destroy();
         this.Config = null;
     }
     if (this.ReloadHelper != null)
     {
         this.ReloadHelper.Destroy();
         this.ReloadHelper = null;
     }
 }
예제 #5
0
 public GeometryProjector(ProjectorConfig config)
 {
     this.Config         = config;
     this.ProjectorIndex = Service.Get <ProjectorManager>().AddProjector(this);
     this.AssetProcessor = new ProjectorAssetProcessor(this);
     Service.Get <EventManager>().RegisterObserver(this, EventId.ForceGeometryReload, EventPriority.Default);
 }
예제 #6
0
        public static void OnDefaultAssetSuccess(GeometryProjector projector)
        {
            ProjectorConfig config = projector.Config;

            projector.Renderer.Render(config);
            projector.Renderer.PostRender(config);
        }
예제 #7
0
        public void Render(ProjectorConfig config)
        {
            if (!config.AssetReady)
            {
                return;
            }
            Animator  component  = config.MainAsset.GetComponent <Animator>();
            Animation component2 = config.MainAsset.GetComponent <Animation>();

            if (component != null)
            {
                if (component.hasRootMotion)
                {
                    component.SetInteger("Motivation", (int)config.AnimState);
                }
                else
                {
                    Service.Logger.ErrorFormat("{0} needs re-rigging, its Animator does not have a root motion.", new object[]
                    {
                        config.AssetName
                    });
                }
            }
            else if (component2 != null)
            {
                string text = config.AnimationName;
                if (string.IsNullOrEmpty(text))
                {
                    text = config.AnimState.ToString();
                }
                if (component2.GetClip(text) != null)
                {
                    component2.Play(text);
                }
            }
            else if (config.MainAsset != null)
            {
                AssetMeshDataMonoBehaviour component3 = config.MainAsset.transform.GetComponent <AssetMeshDataMonoBehaviour>();
                if (component3 != null)
                {
                    List <GameObject> selectableGameObjects = component3.SelectableGameObjects;
                    int i     = 0;
                    int count = selectableGameObjects.Count;
                    while (i < count)
                    {
                        if (!(selectableGameObjects[i] == null))
                        {
                            component = selectableGameObjects[i].GetComponent <Animator>();
                            if (component != null && component.hasRootMotion)
                            {
                                component.SetInteger("Motivation", (int)config.AnimState);
                            }
                        }
                        i++;
                    }
                }
            }
            this.baseRenderer.Render(config);
        }
예제 #8
0
        public static ProjectorConfig GenerateEquipmentConfig(EquipmentVO equipmentVO, UXSprite frameSprite, bool closeup)
        {
            IGeometryVO     vo = ProjectorUtils.DetermineVOForEquipment(equipmentVO);
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(vo, frameSprite, closeup);

            projectorConfig.buildingEquipmentShaderName = ProjectorUtils.GetEquipmentBuildingShaderName(equipmentVO);
            return(projectorConfig);
        }
예제 #9
0
        public static ProjectorConfig GenerateEquipmentConfig(EquipmentVO equipmentVO, Action <RenderTexture, ProjectorConfig> callback, float width, float height)
        {
            IGeometryVO     vo = ProjectorUtils.DetermineVOForEquipment(equipmentVO);
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(vo, callback, width, height);

            projectorConfig.buildingEquipmentShaderName = ProjectorUtils.GetEquipmentBuildingShaderName(equipmentVO);
            return(projectorConfig);
        }
예제 #10
0
        public static ProjectorConfig GenerateGeometryConfig(IGeometryVO vo, Action <RenderTexture, ProjectorConfig> callback, float width, float height)
        {
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(vo, null, false);

            projectorConfig.RenderCallback = callback;
            projectorConfig.RenderWidth    = width;
            projectorConfig.RenderHeight   = height;
            return(projectorConfig);
        }
 public void Render(ProjectorConfig config)
 {
     if (!config.AssetReady)
     {
         return;
     }
     this.Initialize(config);
     this.baseRenderer.Render(config);
 }
예제 #12
0
 public void Render(ProjectorConfig config)
 {
     if (!config.AssetReady)
     {
         return;
     }
     this.shaderMeterComp = Service.Get <EntityViewManager>().CreateMeterShaderComponentIfApplicable(config.MainAsset);
     this.shaderMeterComp.UpdatePercentage(config.MeterValue);
     this.baseRenderer.Render(config);
 }
 public override void Render(ProjectorConfig config)
 {
     if (!config.AssetReady)
     {
         return;
     }
     base.SetupCamera(this.frameSprite.Root.name, config.MainAsset, config.Sharpness, this.frameSprite.Width, this.frameSprite.Height, config.CameraPosition, config.CameraInterest);
     this.SetupScreen(config);
     base.Render(config);
 }
예제 #14
0
 public void Render(ProjectorConfig config)
 {
     if (!config.AssetReady)
     {
         return;
     }
     this.targetObject      = config.MainAsset.gameObject;
     this.iconRotationSpeed = config.IconRotationSpeed;
     Service.ViewTimeEngine.RegisterFrameTimeObserver(this);
     this.baseRenderer.Render(config);
 }
 private void Initialize(ProjectorConfig config)
 {
     if (this.initialized)
     {
         return;
     }
     this.config = config;
     this.EnsureSwapShaderSrc();
     this.CreateNonSharedMaterials(config.MainAsset);
     this.initialized = true;
 }
 public void PostRender(ProjectorConfig config)
 {
     if (config.EnableCrateHoloShaderSwap)
     {
         UITexture projectorUITexture = this.GetProjectorUITexture();
         if (projectorUITexture != null)
         {
             projectorUITexture.shader = this.holoCrateSwapShaderSrc;
         }
     }
     this.baseRenderer.PostRender(config);
 }
예제 #17
0
        public static GeometryProjector GenerateProjector(ProjectorConfig config)
        {
            GeometryProjector geometryProjector = new GeometryProjector(config);

            if (config.FrameSprite != null)
            {
                geometryProjector.Renderer = new SpriteProjectorRenderer(config.FrameSprite, geometryProjector.ProjectorIndex);
            }
            else
            {
                geometryProjector.Renderer = new SurfaceProjectorRenderer(geometryProjector.ProjectorIndex);
            }
            if (config.Metered)
            {
                geometryProjector.Renderer = new ProjectorMeterDecorator(geometryProjector.Renderer);
            }
            geometryProjector.Renderer = new ProjectorOutlineDecorator(geometryProjector.Renderer);
            if (!string.IsNullOrEmpty(config.TrackerName))
            {
                geometryProjector.Renderer = new ProjectorTurretDecorator(geometryProjector.Renderer);
            }
            if (!string.IsNullOrEmpty(config.buildingEquipmentShaderName) && ProjectorUtils.CanBeAnimated(config))
            {
                geometryProjector.Renderer = new ProjectorEquipmentBuildingDecorator(geometryProjector.Renderer);
            }
            else
            {
                geometryProjector.Renderer = new ProjectorShaderSwapDecorator(geometryProjector.Renderer);
            }
            geometryProjector.Renderer = new ProjectorAnimationDecorator(geometryProjector.Renderer);
            bool flag  = config.AnimPreference == AnimationPreference.NoAnimation;
            bool flag2 = config.AnimPreference == AnimationPreference.AnimationPreferred && HardwareProfile.IsLowEndDevice();

            if (!flag && !flag2 && config.IconRotationSpeed > 0f)
            {
                geometryProjector.Renderer = new ProjectorRotationDecorator(geometryProjector.Renderer);
            }
            ProjectorAssetProcessor arg_16C_0 = geometryProjector.AssetProcessor;

            if (ProjectorUtils.< > f__mg$cache0 == null)
            {
                ProjectorUtils.< > f__mg$cache0 = new Action <GeometryProjector>(ProjectorUtils.OnDefaultAssetSuccess);
            }
            Action <GeometryProjector> arg_16C_1 = ProjectorUtils.< > f__mg$cache0;

            if (ProjectorUtils.< > f__mg$cache1 == null)
            {
                ProjectorUtils.< > f__mg$cache1 = new Action <GeometryProjector>(ProjectorUtils.OnDefaultAssetFailure);
            }
            arg_16C_0.LoadAllAssets(arg_16C_1, ProjectorUtils.< > f__mg$cache1);
            return(geometryProjector);
        }
        public void Render(ProjectorConfig config)
        {
            if (!config.AssetReady)
            {
                return;
            }
            GameObject gameObject = UnityUtils.FindGameObject(config.MainAsset, config.TrackerName);

            if (gameObject != null)
            {
                gameObject.transform.localRotation = ProjectorTurretDecorator.DEFAULT_ROTATION;
            }
            this.baseRenderer.Render(config);
        }
 public override void Render(ProjectorConfig config)
 {
     if (!config.AssetReady)
     {
         return;
     }
     if (config.RenderCallback == null)
     {
         Service.Get <StaRTSLogger>().WarnFormat("Neither a sprite nor a RenderCallback was not provided for the projector {0}", new object[]
         {
             config.AssetName
         });
     }
     base.SetupCamera(config.AssetName, config.MainAsset, config.Sharpness, config.RenderWidth, config.RenderHeight, config.CameraPosition, config.CameraInterest);
     base.Render(config);
 }
예제 #20
0
        public void Render(ProjectorConfig config)
        {
            if (!config.AssetReady)
            {
                return;
            }
            if (string.IsNullOrEmpty(config.buildingEquipmentShaderName) || config.AnimPreference == AnimationPreference.NoAnimation || (config.AnimPreference == AnimationPreference.AnimationPreferred && HardwareProfile.IsLowEndDevice()))
            {
                this.baseRenderer.Render(config);
                return;
            }
            this.materialCopies = new List <Material>();
            Dictionary <Material, Material> dictionary = new Dictionary <Material, Material>();
            Shader shader = Service.AssetManager.Shaders.GetShader(config.buildingEquipmentShaderName);
            AssetMeshDataMonoBehaviour component = config.MainAsset.GetComponent <AssetMeshDataMonoBehaviour>();

            if (component != null)
            {
                int count = component.SelectableGameObjects.Count;
                for (int i = 0; i < count; i++)
                {
                    Renderer component2 = component.SelectableGameObjects[i].GetComponent <Renderer>();
                    if (component2.sharedMaterial == null)
                    {
                        Service.Logger.ErrorFormat("sharedMaterial missing on {0}", new object[]
                        {
                            component.SelectableGameObjects[i].name
                        });
                    }
                    else if (dictionary.ContainsKey(component2.sharedMaterial))
                    {
                        component2.sharedMaterial = dictionary[component2.sharedMaterial];
                    }
                    else
                    {
                        Material material = UnityUtils.EnsureMaterialCopy(component2);
                        this.materialCopies.Add(material);
                        dictionary.Add(component2.sharedMaterial, material);
                        material.shader = shader;
                    }
                }
            }
            dictionary.Clear();
            this.baseRenderer.Render(config);
        }
예제 #21
0
        public virtual void Render(ProjectorConfig config)
        {
            this.config = config;
            bool flag  = config.AnimPreference == AnimationPreference.NoAnimation;
            bool flag2 = config.AnimPreference == AnimationPreference.AnimationPreferred && HardwareProfile.IsLowEndDevice();

            this.snapshot = (flag || flag2);
            if (this.snapshot)
            {
                this.renderCallback     = config.RenderCallback;
                this.snapshotFrameCount = config.SnapshotFrameDelay;
                Service.ViewTimeEngine.RegisterFrameTimeObserver(this);
            }
            else if (config.RenderCallback != null)
            {
                config.RenderCallback(this.renderTexture, config);
            }
        }
예제 #22
0
        private void SetupScreen(ProjectorConfig config)
        {
            this.DestroyQuad();
            this.quadGameObject                         = new GameObject(string.Format("Projector Quad ({0})", this.frameSprite.Root.name));
            this.quadGameObject.layer                   = this.frameSprite.Root.layer;
            this.quadGameObject.transform.parent        = this.frameSprite.Root.transform;
            this.quadGameObject.transform.localPosition = Vector3.zero;
            this.quadGameObject.transform.localScale    = Vector3.one;
            this.uiTexture             = this.quadGameObject.AddComponent <UITexture>();
            this.uiTexture.mainTexture = this.renderTexture;
            UXElement uXElement = new UXElement(this.frameSprite.UXCamera, this.quadGameObject, null);

            uXElement.Width       = this.frameSprite.Width;
            uXElement.Height      = this.frameSprite.Height;
            uXElement.WidgetDepth = this.frameSprite.WidgetDepth;
            if (config.Tint != Color.white)
            {
                this.uiTexture.color = config.Tint;
            }
        }
        public void Render(ProjectorConfig config)
        {
            if (!config.AssetReady)
            {
                return;
            }
            Animator component = config.MainAsset.GetComponent <Animator>();

            if (component != null)
            {
                if (component.hasRootMotion)
                {
                    component.SetInteger("Motivation", (int)config.AnimState);
                }
                else
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("{0} needs re-rigging, its Animator does not have a root motion.", new object[]
                    {
                        config.AssetName
                    });
                }
            }
            else
            {
                Animation component2 = config.MainAsset.GetComponent <Animation>();
                if (component2 != null)
                {
                    string text = config.AnimationName;
                    if (string.IsNullOrEmpty(text))
                    {
                        text = config.AnimState.ToString();
                    }
                    if (component2.GetClip(text) != null)
                    {
                        component2.Play(text);
                    }
                }
            }
            this.baseRenderer.Render(config);
        }
예제 #24
0
        public static ProjectorConfig GenerateGeometryConfig(IGeometryVO vo, UXSprite frameSprite, bool closeup)
        {
            ProjectorConfig projectorConfig = new ProjectorConfig();

            projectorConfig.IconRotationSpeed = vo.IconRotationSpeed;
            projectorConfig.AnimPreference    = AnimationPreference.NoAnimation;
            projectorConfig.AssetName         = vo.IconAssetName;
            projectorConfig.closeup           = closeup;
            if (projectorConfig.closeup)
            {
                projectorConfig.CameraPosition = vo.IconCloseupCameraPosition;
                projectorConfig.CameraInterest = vo.IconCloseupLookatPosition;
            }
            else
            {
                projectorConfig.CameraPosition = vo.IconCameraPosition;
                projectorConfig.CameraInterest = vo.IconLookatPosition;
            }
            projectorConfig.AnimState   = AnimState.Idle;
            projectorConfig.FrameSprite = frameSprite;
            return(projectorConfig);
        }
예제 #25
0
 public void Destroy()
 {
     Service.ProjectorManager.RemoveProjector(this);
     if (this.AssetProcessor != null)
     {
         this.AssetProcessor.UnloadAllAssets(null);
         this.AssetProcessor = null;
     }
     if (this.Renderer != null)
     {
         this.Renderer.Destroy();
         this.Renderer = null;
     }
     if (this.Config != null)
     {
         this.Config.Destroy();
         this.Config = null;
     }
     if (this.ReloadHelper != null)
     {
         this.ReloadHelper.Destroy();
         this.ReloadHelper = null;
     }
 }
예제 #26
0
 public void PostRender(ProjectorConfig config)
 {
     this.baseRenderer.PostRender(config);
 }
예제 #27
0
 private static bool CanBeAnimated(ProjectorConfig config)
 {
     return(config.AnimPreference == AnimationPreference.AnimationAlways || (config.AnimPreference == AnimationPreference.AnimationPreferred && !HardwareProfile.IsLowEndDevice()));
 }
 public virtual void PostRender(ProjectorConfig config)
 {
 }
예제 #29
0
        public static ProjectorConfig GenerateBuildingConfig(BuildingTypeVO vo, UXSprite frameSprite)
        {
            ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(vo, frameSprite, false);
            BuildingType    type            = vo.Type;

            if (type != BuildingType.Barracks)
            {
                if (type != BuildingType.Turret && type != BuildingType.Storage)
                {
                    if (type != BuildingType.Armory)
                    {
                        projectorConfig.AnimationName = "Active";
                    }
                    else
                    {
                        projectorConfig.AnimationName = "Idle";
                    }
                }
                else
                {
                    projectorConfig.AnimationName = null;
                }
            }
            else
            {
                projectorConfig.AnimationName = "IdleClosed";
            }
            BuildingType type2 = vo.Type;

            switch (type2)
            {
            case BuildingType.ChampionPlatform:
                projectorConfig.AttachmentAssets = new string[]
                {
                    vo.AssetName
                };
                return(projectorConfig);

            case BuildingType.Housing:
            case BuildingType.Squad:
IL_8F:
                if (type2 == BuildingType.Turret)
                {
                    if (!string.IsNullOrEmpty(vo.TurretUid))
                    {
                        TurretTypeVO turretTypeVO = Service.StaticDataController.Get <TurretTypeVO>(vo.TurretUid);
                        projectorConfig.TrackerName = turretTypeVO.TrackerName;
                    }
                    return(projectorConfig);
                }
                if (type2 != BuildingType.Trap)
                {
                    return(projectorConfig);
                }
                projectorConfig.SnapshotFrameDelay = 4;
                return(projectorConfig);

            case BuildingType.Starport:
                projectorConfig.Metered    = true;
                projectorConfig.MeterValue = 1f;
                return(projectorConfig);
            }
            goto IL_8F;
        }
 public override void PostRender(ProjectorConfig config)
 {
     base.PostRender(config);
 }