コード例 #1
0
 protected override void Initialize(FogOfWarSystem source, Texture displayTexture)
 {
     displayMat = new Material(Shader.Find("Hidden/FOWSeeThroughShader"))
     {
         mainTexture = displayTexture
     };
     GenerateDisplayMesh(source.Size);
 }
コード例 #2
0
 protected override void Initialize(FogOfWarSystem source, Texture displayTexture, int renderQueue = 0)
 {
     displayMat = new Material(Shader.Find("Hidden/FOWSeeThroughShader"))
     {
         mainTexture = displayTexture
     };
     if (renderQueue > 0)
     {
         displayMat.renderQueue = renderQueue;
     }
     GenerateDisplayMesh(source.Size);
 }
コード例 #3
0
 protected override void Initialize(FogOfWarSystem source, Texture displayTexture)
 {
     projector = new GameObject("FogProjector").AddComponent <Projector>();
     projector.transform.parent        = source.transform;
     projector.transform.localPosition = source.transform.position + new Vector3(source.Size * 0.5f, clipTop, source.Size * 0.5f);
     projector.orthographic            = true;
     projector.orthographicSize        = source.Size * 0.5f;
     projector.farClipPlane            = Mathf.Abs(clipTop - clipBottom);
     projector.transform.localRotation = Quaternion.Euler(90, 0, 0);
     projector.material = new Material(Shader.Find("Hidden/FOWProjectorShader"))
     {
         mainTexture = displayTexture
     };
     projector.gameObject.hideFlags = HideFlags.HideAndDontSave;
 }
コード例 #4
0
        public static void RedrawFogOfWar(AbstractActor activeActor)
        {
            if (!Mod.Config.FogOfWar.RedrawFogOfWarOnActivation)
            {
                return;
            }

            FogOfWarSystem fowSystem = LazySingletonBehavior <FogOfWarView> .Instance.FowSystem;

            if (fowSystem == null)
            {
                Mod.Log.Error?.Write("FogOfWarSystem could not be found - this should never happen!");
                return;
            }

            Mod.Log.Debug?.Write($"Redrawing FOW for actor: {CombatantUtils.Label(activeActor)}");

            Traverse             viewersT = Traverse.Create(fowSystem).Field("viewers");
            List <AbstractActor> viewers  = viewersT.GetValue <List <AbstractActor> >();

            viewers.Clear();

            // Reset FoW to being unseen
            fowSystem.WipeToValue(Mod.Config.FogOfWar.ShowTerrainThroughFogOfWar ?
                                  FogOfWarState.Surveyed : FogOfWarState.Unknown);

            // Add the actor as a viewer
            fowSystem.AddViewer(activeActor);

            // Check lancemates; if they have vision sharing add them as well
            foreach (string lanceGuid in activeActor?.lance?.unitGuids)
            {
                if (!lanceGuid.Equals(activeActor.GUID))
                {
                    ICombatant lanceMateC = activeActor.Combat.FindCombatantByGUID(lanceGuid);
                    if (lanceMateC is AbstractActor lanceActor)
                    {
                        EWState lanceState = new EWState(lanceActor);
                        if (lanceState.SharesVision())
                        {
                            fowSystem.AddViewer(lanceActor);
                        }
                    }
                }
            }
        }
コード例 #5
0
        public static bool Prefix(FogOfWarSystem __instance, AbstractActor unit, List <AbstractActor> ___viewers)
        {
            if (__instance == null || unit == null)
            {
                return(true);
            }

            if (unit.IsDead || !__instance.Combat.HostilityMatrix.IsLocalPlayerFriendly(unit.team))
            {
                // Skip processing if the unit is an enemy or dead
                return(false);
            }
            else if (__instance.Combat.HostilityMatrix.IsLocalPlayerFriendly(unit.team) && !___viewers.Contains(unit))
            {
                __instance.AddViewer(unit);
            }

            return(true);
        }
コード例 #6
0
        public override void DrawGizmos(FogOfWarSystem source)
        {
            var height = Mathf.Abs(clipTop - clipBottom);

            Gizmos.DrawWireCube(source.transform.position + new Vector3(source.Size * 0.5f, clipTop - height * 0.5f, source.Size * 0.5f), new Vector3(source.Size, height, source.Size));
        }
コード例 #7
0
 void Start()
 {
     fow = FindObjectOfType <FogOfWarSystem>();
 }
コード例 #8
0
 protected abstract void Initialize(FogOfWarSystem source, Texture displayTexture, int renderQueue = 0);
コード例 #9
0
 public void Init(FogOfWarSystem source, Texture displayTexture, int renderQueue)
 {
     shaderBlurID  = Shader.PropertyToID("_Blur");
     shaderColorID = Shader.PropertyToID("_Color");
     Initialize(source, displayTexture, renderQueue);
 }
コード例 #10
0
        public virtual void DrawGizmos(FogOfWarSystem source)
        {
            var box = new Vector3(source.Size, 0, source.Size);

            Gizmos.DrawWireCube(new Vector3(source.transform.position.x + box.x * 0.5f, 0, source.transform.position.z + box.z * 0.5f), box);
        }
コード例 #11
0
ファイル: FOWRenderer.cs プロジェクト: soulhez/SimpleFogOfWar
 protected abstract void Initialize(FogOfWarSystem source, Texture displayTexture);