Ejemplo n.º 1
0
        public override void OnInitialized()
        {
            worlditem.OnVisible   += OnVisible;
            worlditem.OnInvisible += OnInvisible;
            worlditem.OnActive    += OnActive;

            Visitable visitable = null;

            if (worlditem.Is <Visitable>(out visitable))
            {
                visitable.OnPlayerVisit += OnPlayerVisit;
                visitable.OnPlayerLeave += OnPlayerLeave;
            }

            Revealable revealable = null;

            if (worlditem.Is <Revealable>(out revealable))
            {
                revealable.OnReveal += OnReveal;
            }

            State.IsCivilized = false;
            if (worlditem.Is <City>())
            {
                State.IsCivilized = true;
            }
        }
Ejemplo n.º 2
0
        public void CreatePathMarkerProps()
        {
            if (HasPathMarkerProps)
            {
                return;
            }

            mProps = new PathMarkerInstanceTemplate();
            switch (worlditem.State)
            {
            case "PathMarker":
            default:
                mProps.Type = PathMarkerType.PathMarker;
                break;

            case "CrossMarker":
                mProps.Type = PathMarkerType.CrossMarker;
                break;
            }
            mProps.Position = worlditem.tr.position;
            mProps.Rotation = worlditem.tr.rotation.eulerAngles;
            mProps.Owner    = this;

            Visitable visitable = worlditem.Get <Visitable>();

            mProps.Visitable = visitable.State;

            Revealable revealable = worlditem.Get <Revealable>();

            mProps.Revealable = revealable.State;
        }
Ejemplo n.º 3
0
        public void RefreshPathMarkerProps(bool setPosition)
        {
            if (!mInitialized)
            {
                return;
            }

            if (HasPathMarkerProps)
            {
                if (setPosition)
                {
                    worlditem.ActiveState = WIActiveState.Active;
                    mHit.feetPosition     = mProps.Position;
                    mHit.overhangHeight   = 4.0f;
                    mHit.groundedHeight   = 5.0f;
                    mHit.ignoreWorldItems = true;                                                            //we want path markers to appear below people / signs / etc
                    mHit.feetPosition.y   = GameWorld.Get.TerrainHeightAtInGamePosition(ref mHit);
                    worlditem.tr.position = mHit.feetPosition;
                    worlditem.tr.rotation = Quaternion.Euler(0f, mProps.Rotation.y, 0f);
                    //update the props position based on the new in-game height
                    Props.Position = mHit.feetPosition;
                }

                Visitable visitable = worlditem.Get <Visitable>();
                visitable.State = Props.Visitable;

                Revealable revealable = worlditem.Get <Revealable>();
                revealable.State = Props.Revealable;

                //we only care about other items if we're a path origin
                //OR if we're the terminal of an active path
                if (Flags.Check((uint)PathMarkerType.PathOrigin, (uint)mProps.Type, Flags.CheckType.MatchAny) || (IsActive && IsTerminal))
                {
                    visitable.Trigger.enabled = true;
                    if (visitable.Trigger.VisitableCollider != null)
                    {
                        SphereCollider sc = visitable.Trigger.VisitableCollider as SphereCollider;
                        sc.radius = Globals.PathOriginTriggerRadius;
                    }
                    else
                    {
                        SphereCollider sc = visitable.Trigger.gameObject.AddComponent <SphereCollider>();
                        sc.radius = Globals.PathOriginTriggerRadius;
                        visitable.Trigger.VisitableCollider = sc;
                    }
                    worlditem.State = "CrossMarker";
                }
                else
                {
                    visitable.Trigger.enabled = false;
                    worlditem.State           = "PathMarker";
                }
            }
        }
Ejemplo n.º 4
0
        public override void OnInitialized()
        {
            Location location = null;

            if (worlditem.Is <Location> (out location))
            {
                location.UnloadOnInvisible = false;
            }

            worlditem.OnActive       += OnVisible;
            worlditem.OnVisible      += OnVisible;
            worlditem.OnInvisible    += OnInvisible;
            worlditem.OnAddedToGroup += OnAddedToGroup;

            mSpawningFish   = false;
            mDespawningFish = false;

            Visitable visitable = null;

            if (worlditem.Is <Visitable> (out visitable))
            {
                visitable.PlayerOnly             = false;
                visitable.OnPlayerVisit         += OnPlayerVisit;
                visitable.OnPlayerLeave         += OnPlayerLeave;
                visitable.OnItemOfInterestVisit += OnItemOfInterestVisit;
                visitable.OnItemOfInterestLeave += OnItemOfInterestLeave;
                visitable.ItemsOfInterest.Add("Creature");
                visitable.ItemsOfInterest.Add("WaterTrap");
            }

            Revealable revealable = null;

            if (worlditem.Is <Revealable> (out revealable))
            {
                revealable.State.CustomMapSettings = true;
                revealable.State.IconStyle         = MapIconStyle.Small;
                revealable.State.LabelStyle        = MapLabelStyle.None;
                revealable.State.IconName          = "MapIconFishDen";
            }
        }
Ejemplo n.º 5
0
        public override void OnInitialized()
        {
            //hide on map
            Revealable revealable = worlditem.Get <Revealable> ();

            revealable.State.CustomMapSettings = true;
            revealable.State.IconStyle         = MapIconStyle.None;
            revealable.State.LabelStyle        = MapLabelStyle.None;

            Den = worlditem.Get <CreatureDen> ();
            WorldClock.Get.TimeActions.Subscribe(TimeActionType.NightTimeStart, new ActionListener(NightTimeStart));
            WorldClock.Get.TimeActions.Subscribe(TimeActionType.DaytimeStart, new ActionListener(DaytimeStart));

            if (WorldClock.IsNight)
            {
                if (!mDispensingOrbs)
                {
                    mDispensingOrbs = true;
                    StartCoroutine(DispenseOrbs());
                }
            }
        }
Ejemplo n.º 6
0
        public override void OnEditorRefresh()
        {
            mWorldItem = gameObject.GetComponent <WorldItem>();
            if (string.IsNullOrEmpty(State.Name.FileName) || State.Name.FileName != name)
            {
                State.Name.FileName = name;
            }
            worlditem.Props.Name.FileName = State.Name.FileName;

            //if our parent group is the chunk then we should unload on invisible
            if (worlditem.Group != null && (worlditem.Group.name == "AG" || worlditem.Group.name == "BG" || worlditem.Group.name == "TR"))
            {
                State.UnloadOnInvisible = true;
            }
            else
            {
                State.UnloadOnInvisible = false;
            }

            Revealable revealable = null;

            if (gameObject.HasComponent <Revealable>(out revealable) && !revealable.State.CustomMapSettings)
            {
                switch (State.Type)
                {
                case "CapitalCity":
                    revealable.State.IconStyle  = MapIconStyle.AlwaysVisible;
                    revealable.State.LabelStyle = MapLabelStyle.AlwaysVisible;
                    revealable.State.IconName   = "MapIconCapitalCity";
                    break;

                case "City":
                    revealable.State.IconStyle  = MapIconStyle.Large;
                    revealable.State.LabelStyle = MapLabelStyle.MouseOver;
                    revealable.State.IconName   = "MapIconCity";
                    break;

                case "Shingle":
                    //let the various structure scripts take care of this
                    break;

                case "District":
                default:
                    revealable.State.IconStyle  = MapIconStyle.None;
                    revealable.State.LabelStyle = MapLabelStyle.Descriptive;
                    break;

                case "Campsite":
                    revealable.State.IconStyle  = MapIconStyle.Large;
                    revealable.State.LabelStyle = MapLabelStyle.MouseOver;
                    revealable.State.IconName   = "MapIconCampsite";
                    break;

                case "Cemetary":
                    revealable.State.IconStyle  = MapIconStyle.Large;
                    revealable.State.LabelStyle = MapLabelStyle.MouseOver;
                    revealable.State.IconName   = "MapIconCemetary";
                    break;

                case "WayStone":
                    revealable.State.IconStyle  = MapIconStyle.Medium;
                    revealable.State.LabelStyle = MapLabelStyle.None;
                    revealable.State.IconName   = "MapIconWayStone";
                    break;

                case "Gateway":
                    revealable.State.IconStyle  = MapIconStyle.Large;
                    revealable.State.LabelStyle = MapLabelStyle.None;
                    revealable.State.IconName   = "MapIconGateway";
                    break;

                case "CrossRoads":
                    revealable.State.IconStyle  = MapIconStyle.Large;
                    revealable.State.LabelStyle = MapLabelStyle.None;
                    revealable.State.IconName   = "MapIconCrossRoads";
                    break;
                }
            }

            if (State.Name.CommonName == "Shingle")
            {
                State.Name.CommonName = Frontiers.Data.GameData.AddSpacesToSentence(State.Name.FileName);
            }

            //make sure our visible radius encompasses our child location visible radius
            Bounds activeRadiusBounds    = new Bounds(transform.position, Vector3.one);
            Bounds visibleDistanceBounds = new Bounds(transform.position, Vector3.one);

            foreach (Transform child in transform)
            {
                WorldItem childWorlditem = null;
                if (child.gameObject.HasComponent <WorldItem>(out childWorlditem))
                {
                    Bounds childActiveRadiusBounds    = new Bounds(childWorlditem.transform.position, Vector3.one * childWorlditem.Props.Local.ActiveRadius);
                    Bounds childVisibleDistanceBounds = new Bounds(childWorlditem.transform.position, Vector3.one * (childWorlditem.Props.Local.VisibleDistance + childWorlditem.Props.Local.ActiveRadius));
                    activeRadiusBounds.Encapsulate(childActiveRadiusBounds);
                    visibleDistanceBounds.Encapsulate(visibleDistanceBounds);
                }
            }
            float maxActiveRadius    = Mathf.Max(Mathf.Max(activeRadiusBounds.size.x, activeRadiusBounds.size.y), activeRadiusBounds.size.z);
            float maxVisibleDistance = Mathf.Max(Mathf.Max(visibleDistanceBounds.size.x, visibleDistanceBounds.size.y), visibleDistanceBounds.size.z);

            worlditem.Props.Local.ActiveRadius    = Mathf.Max(worlditem.Props.Local.ActiveRadius, maxActiveRadius);
            worlditem.Props.Local.VisibleDistance = Mathf.Max(worlditem.Props.Local.VisibleDistance, maxVisibleDistance - worlditem.Props.Local.ActiveRadius);
        }