Esempio n. 1
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var duration = trigger.Text.NextTimeSpan();
                var id       = trigger.Text.NextUInt();


                var worldEvent = WorldEventMgr.GetEvent(id);

                if (worldEvent == null)
                {
                    trigger.Reply("Invalid World Event {0} specified", id);
                    return;
                }

                if (duration == null)
                {
                    trigger.Reply("Invalid Duration specified {0}", EnglishParamInfo);
                    return;
                }

                if (duration > worldEvent.Occurence)
                {
                    trigger.Reply("Invalid Duration {0} specified, must be less than the occurence {1}", duration, worldEvent.Occurence);
                    return;
                }
                worldEvent.Duration = (TimeSpan)duration;
                WorldEvent.CalculateEventDelays(worldEvent);
            }
Esempio n. 2
0
    public void onTouch(Vector3 e)
    {
        Ray        ray = Camera.main.ScreenPointToRay(e);
        WorldEvent eventForObj = null, eventForParticle = null;

        float dis;

        if (ledWorld.IntersectRay(ray, out dis))
        {
            Vector3 hit = ray.origin + dis * Vector3.Normalize(ray.direction);
            //Debug.Log("ray " + hit + " " + Input.mousePosition);

            glow.transform.position = hit;

            // translate to the obj and particle world position and OnEvent()
            eventForObj = new WorldEvent()
            {
                position = TranslatePosition(ledWorld, objectsWorld, hit)
            };
            eventForParticle = new WorldEvent()
            {
                position = TranslatePosition(ledWorld, particlesWorld, hit)
            };

            glowps.Play();

            vox.OnInteractionInput(eventForObj);
            ripple.transform.position = eventForParticle.position;
            rippleps.Play();
            pvox.OnInteractionInput(eventForParticle);
        }
    }
Esempio n. 3
0
    // Get the next
    protected WorldEvent NextEvent()
    {
        string data = Encoding.UTF8.GetString(world.Receive());

        Console.WriteLine("received: `{0}`", data);
        string[] e          = data.Split(" ".ToCharArray());
        var      worldEvent = new WorldEvent();

        worldEvent.type       = Event.Default;
        worldEvent.properties = null;

        if (e[0] == id && e[1] == "new")
        {
            //  This message has the format:
            //      <hash> new
            //         id <id>
            //         <key0> <value0>
            //         <key1> <value1>
            //         ...
            //  (Not including newlines -- formatted for readability)
            //  This is building that dictionary to pass to the script
            //  so it can update from the network.
            Debug.Assert(e.Length >= 4);
            worldEvent.properties = new Dictionary <string, string>();
            for (int i = 2; i < e.Length; i += 2)
            {
                worldEvent.properties[e[i]] = e[i + 1];
            }
        }
        return(worldEvent);
    }
Esempio n. 4
0
        public override string ToLink(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null)
        {
            //if (link)
            //{
            //    string title = Type.GetDescription();
            //    title += "&#13";
            //    title += "Events: " + Events.Count;

            //    string linkedString = "";
            //    if (pov != this)
            //    {
            //        linkedString = Icon + "<a href = \"structure#" + GlobalID + "\" title=\"" + title + "\">" + Name + "</a>";
            //    }
            //    else
            //    {
            //        linkedString = Icon + "<a title=\"" + title + "\">" + HTMLStyleUtil.CurrentDwarfObject(Name) + "</a>";
            //    }
            //    return linkedString;
            //}
            //else
            //{
            //    return Icon + Name;
            //}
            return(Name);
        }
Esempio n. 5
0
        public override string ToLink(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null)
        {
            if (link)
            {
                string title = "";
                if (StructureSubType != StructureSubType.Unknown)
                {
                    title += StructureSubType.GetDescription();
                }
                else
                {
                    title += Type.GetDescription();
                }
                title += "&#13";
                title += "Events: " + Events.Count;

                string linkedString = "";
                if (pov != this)
                {
                    linkedString = Icon + "<a href = \"structure#" + GlobalId + "\" title=\"" + title + "\">" + Name + "</a>";
                }
                else
                {
                    linkedString = Icon + "<a title=\"" + title + "\">" + HtmlStyleUtil.CurrentDwarfObject(Name) + "</a>";
                }
                return(linkedString);
            }
            return(Icon + Name);
        }
Esempio n. 6
0
 public static void AddEvent(this WorldObject worldObject, WorldEvent worldEvent)
 {
     if (worldObject != null)
     {
         worldObject.Events.Add(worldEvent);
     }
 }
    IEnumerator CheckForNewEvents()
    {
        while (true)
        {
            // Right now this will grab an event that is stored on this script, but later it might read it from an external database
            WorldEvent newEvent = GetNewEvent(Random.Range(0, eventArray.Length));

            if (curWorldEvent != null)
            {
                if (newEvent.eventType != curWorldEvent.eventType)
                {
                    isGettingNewEvent = false;
                    curWorldEvent     = newEvent;
                    yield break;
                }
            }
            else
            {
                isGettingNewEvent = false;
                curWorldEvent     = newEvent;
                yield break;
            }


            // If we dont get a new random event that is of a type different to the current one, we wait until next month!
            yield return(new WaitForSeconds(monthInSeconds));
        }
    }
        public override string ToLink(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null)
        {
            if (this == Unknown)
            {
                return(Name);
            }

            if (link)
            {
                string icon = GetIcon();
                if (pov == null || pov != this)
                {
                    if (pov != null && pov.GetType() == typeof(BeastAttack) && (pov as BeastAttack)?.Beast == this) //Highlight Beast when printing Beast Attack Log
                    {
                        return(icon + "<a href=\"hf#" + Id + "\" title=\"" + Title + "\"><font color=#339900>" + ShortName + "</font></a>");
                    }

                    if (worldEvent != null)
                    {
                        return("the " + GetRaceStringByWorldEvent(worldEvent) + " " + icon + "<a href=\"hf#" + Id + "\" title=\"" + Title + "\">" + Name + "</a>");
                    }
                    return("the " + RaceString + " " + icon + "<a href=\"hf#" + Id + "\" title=\"" + Title + "\">" + Name + "</a>");
                }
                return("<a href=\"hf#" + Id + "\" title=\"" + Title + "\">" + HtmlStyleUtil.CurrentDwarfObject(ShortName) + "</a>");
            }
            if (pov == null || pov != this)
            {
                if (worldEvent != null)
                {
                    return(GetRaceStringByWorldEvent(worldEvent) + " " + Name);
                }
                return(RaceString + " " + Name);
            }
            return(ShortName);
        }
Esempio n. 9
0
        /// <summary>
        /// Retrieves the amount of time since the last active time for the given event, using the megaserver timetables
        /// </summary>
        /// <param name="evt">The event to retrieve the time for</param>
        /// <returns>Timespan containing the amount of time since the event was last active</returns>
        public TimeSpan GetTimeSinceActive(WorldEvent evt)
        {
            TimeSpan timeSinceActive = TimeSpan.MinValue;

            if (evt != null)
            {
                // Find the next time
                var lastTime = evt.ActiveTimes.LastOrDefault(activeTime => (this.timeProvider.CurrentTime.TimeOfDay - activeTime.Time) >= TimeSpan.FromSeconds(0));

                // If there is no next time, then take the first time
                if (lastTime == null)
                {
                    lastTime = evt.ActiveTimes.FirstOrDefault();
                    if (lastTime != null)
                    {
                        timeSinceActive = (this.timeProvider.CurrentTime.TimeOfDay - lastTime.Time) + TimeSpan.FromHours(24);
                    }
                }
                else
                {
                    // Calculate the number of seconds until the next time
                    timeSinceActive = this.timeProvider.CurrentTime.TimeOfDay - lastTime.Time;
                }
            }
            return(timeSinceActive);
        }
Esempio n. 10
0
 void Awake()
 {
     GameManager.worldEvent += EventManager;
     GameManager.nextTurn += NextTurn;
     WorldManager.onHexClick += OnHexClick;
     worldManager = GameObject.FindObjectOfType<WorldManager>();
 }
Esempio n. 11
0
    public void SetupPoolGroup()
    {
        allPoolPieces.AddRange(thisPathedArea.thisAreaProceduralPieces);
        for (int i = 0; i < thisPathedArea.connectionPieces.Count; i++)
        {
            allPoolPieces.Add(thisPathedArea.connectionPieces[i].thisConnectionPiece);
        }

        for (int i = 0; i < thisPPGData.resourceNode_Data.Count; i++)
        {
            ResourceNode rn = fixedAreaResourceNodes.Find(x => x.optionalUniqueID == thisPPGData.resourceNode_Data[i].resourceNodeID);
            if (rn != null)
            {
                rn.nodeData = thisPPGData.resourceNode_Data[i];
            }
        }

        for (int i = 0; i < thisPPGData.worldEvent_Data.Count; i++)
        {
            WorldEvent we = fixedAreaWorldEvents.Find(x => x.thisEventData.eventID == thisPPGData.worldEvent_Data[i].eventID);
            if (we != null)
            {
                we.SetupEvent(thisPPGData.worldEvent_Data[i]);
            }
        }
    }
Esempio n. 12
0
        public override void NetReceive(BinaryReader reader)
        {
            CurrentEvent = null;
            if (reader.ReadBoolean())
            {
                var st = reader.ReadString();

                foreach (WorldEvent it in TwitchChat.EventsPool)
                {
                    if (it.GetType().Name == st)
                    {
                        StartWorldEvent(it);

                        if (it.Type == InvasionType.Invasion)
                        {
                            Main.invasionProgressWave = reader.ReadInt32();
                            Main.invasionSizeStart    = reader.ReadInt32();
                            Main.invasionSize         = reader.ReadInt32();
                            Main.invasionType         = reader.ReadInt32();
                            Main.invasionX            = reader.ReadDouble();
                            Main.invasionProgress     = reader.ReadInt32();
                        }

                        break;
                    }
                }

                if (CurrentEvent == null)
                {
                    Main.NewTextMultiline($"You use outdated version of mod, were {st} event not registered!", c: Color.Red);
                }
            }
        }
Esempio n. 13
0
        public override void Initialize()
        {
            base.Initialize();

            if (CurrentEvent != null)
            {
                CurrentEvent.EventEnd(this, (TwitchChat)mod);
                CurrentEvent = null;
            }

            TickUpdate?.Invoke(false);
            //Build new Scheduler based on main thread with clock based on world ticks (kind'a'like we root to game time instead real time schedule)
            WorldScheduler = new Scheduler(Thread.CurrentThread, new GameTickClock(this));

            RealtimeScheduler = new Scheduler(Thread.CurrentThread);

            lastDayState = Main.dayTime;

            if (ModLoader.version < new Version(0, 11, 5))
            {
                if (Main.netMode == NetmodeID.MultiplayerClient && mod.IsNetSynced)
                {
                    ModPacket p = mod.GetPacket();
                    p.Write((byte)TwitchChat.NetPacketType.Custom);
                    p.Write("NetSend");
                    p.Write(true);
                    p.Send(256);
                }
            }
        }
Esempio n. 14
0
    public void OnInteractionInput(WorldEvent e)
    {
        switch (e.gesture)
        {
        case KinectGestures.Gestures.Wave:
        case KinectGestures.Gestures.SwipeLeft:
        case KinectGestures.Gestures.SwipeRight:
        case KinectGestures.Gestures.SwipeUp:
        case KinectGestures.Gestures.SwipeDown:
        case KinectGestures.Gestures.Push:
        case KinectGestures.Gestures.Pull:
            break;

        default:
            return;
        }

        fishvelocity = 5 * WalkVelocity(e.position, transform.position);
        Quaternion q = transform.rotation;
        Vector3    v = e.position - objectsWorld.center;

        v.y = 0;
        v   = Vector3.Normalize(v);
        float angle = v.z > 0 ? Mathf.Acos(v.x) : 2 * Mathf.PI - Mathf.Acos(v.x);

        q.eulerAngles      = new Vector3(90, 360f - 360f * angle / (2 * Mathf.PI), 0);
        transform.rotation = q;
    }
Esempio n. 15
0
        public string Print(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null)
        {
            var identityString = "the ";

            if (Race != null && Race != CreatureInfo.Unknown)
            {
                identityString += Race.NameSingular.ToLower();
            }
            else
            {
                identityString += HistoricalFigure.GetRaceString();
            }

            if (!string.IsNullOrWhiteSpace(Profession))
            {
                identityString += " " + Profession.ToLower();
            }
            var icon = !string.IsNullOrWhiteSpace(Caste) ? GetIcon() : HistoricalFigure.GetIcon();

            if (!string.IsNullOrWhiteSpace(icon))
            {
                identityString += " " + icon;
            }
            identityString += " " + Name;
            if (Entity != null)
            {
                identityString += " of ";
                identityString += Entity.ToLink(link, pov, worldEvent);
            }
            return(identityString);
        }
Esempio n. 16
0
 void Awake()
 {
     GameManager.worldEvent  += EventManager;
     GameManager.nextTurn    += NextTurn;
     WorldManager.onHexClick += OnHexClick;
     worldManager             = GameObject.FindObjectOfType <WorldManager>();
 }
Esempio n. 17
0
        public override string ToLink(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null)
        {
            string name;

            if (Type == "Cavern")
            {
                name = "the depths of the world";
            }
            else if (Type == "Underworld")
            {
                name = "the Underworld";
            }
            else
            {
                name = "an underground region (" + Type + ")";
            }

            if (link)
            {
                string title = Type;
                title += "&#13";
                title += "Events: " + Events.Count;

                if (pov != this)
                {
                    return(Icon + "<a href = \"uregion#" + Id + "\" title=\"" + title + "\">" + name + "</a>");
                }

                return(Icon + "<a title=\"" + title + "\">" + HtmlStyleUtil.CurrentDwarfObject(name) + "</a>");
            }
            return(name);
        }
Esempio n. 18
0
        /// <summary>
        /// Retrieves the current state of the given event
        /// </summary>
        /// <param name="evt">The event to retrieve the state of</param>
        /// <returns>The current state of the input event</returns>
        public Data.Enums.EventState GetState(WorldEvent evt)
        {
            var state = Data.Enums.EventState.Unknown;

            if (evt != null)
            {
                var timeUntilActive = this.GetTimeUntilActive(evt);
                var timeSinceActive = this.GetTimeSinceActive(evt);

                if (timeSinceActive >= TimeSpan.FromTicks(0) &&
                    timeSinceActive < evt.Duration.Time)
                {
                    state = Data.Enums.EventState.Active;
                }
                else if (timeUntilActive >= TimeSpan.FromSeconds(0) &&
                         timeUntilActive < evt.WarmupDuration.Time)
                {
                    state = Data.Enums.EventState.Warmup;
                }
                else
                {
                    state = Data.Enums.EventState.Inactive;
                }
            }

            return(state);
        }
Esempio n. 19
0
        public override string ToLink(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null)
        {
            if (link)
            {
                string title = Type;
                title += "&#13";
                title += Attacker.PrintEntity(false) + " (Attacker)";
                title += "&#13";
                title += Defender.PrintEntity(false) + " (Defender)";
                title += "&#13";
                title += "Deaths: " + DeathCount + " | (" + StartYear + " - " + (EndYear == -1 ? "Present" : EndYear.ToString()) + ")";

                string linkedString = "";
                if (pov != this)
                {
                    linkedString = Icon + "<a href = \"collection#" + Id + "\" title=\"" + title + "\"><font color=\"#6E5007\">" + Name + "</font></a>";
                }
                else
                {
                    linkedString = Icon + "<a title=\"" + title + "\">" + HtmlStyleUtil.CurrentDwarfObject(Name) + "</a>";
                }
                return(linkedString);
            }
            return(Name);
        }
Esempio n. 20
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var occurence = trigger.Text.NextTimeSpan();
                var id        = trigger.Text.NextUInt();


                var worldEvent = WorldEventMgr.GetEvent(id);

                if (worldEvent == null)
                {
                    trigger.Reply("Invalid World Event {0} specified", id);
                    return;
                }

                if (occurence == null)
                {
                    trigger.Reply("Invalid Occurence specified {0}", EnglishParamInfo);
                    return;
                }

                if (occurence < worldEvent.Duration)
                {
                    trigger.Reply("Invalid Occurence {0} specified, must be greater than the duration {1}", occurence, worldEvent.Duration);
                    return;
                }
                worldEvent.Occurence = (TimeSpan)occurence;
                WorldEvent.CalculateEventDelays(worldEvent);
            }
Esempio n. 21
0
 public void PushTriggeredEvent(WorldEvent worldEvent)
 {
     triggeredEvents.Enqueue(worldEvent);
     if (!eventDialogOpened)
     {
         ShowNextTriggeredEventDialog();
     }
 }
Esempio n. 22
0
    public WorldEventSnapshot(WorldEvent e)
    {
        EventType = e.GetType();

        TriggerDate = e.TriggerDate;
        SpawnDate   = e.SpawnDate;
        Id          = e.Id;
    }
Esempio n. 23
0
        /// <summary>Finalize this NPCSpawnEntry</summary>
        /// <param name="addToPool">If set to false, will not try to add it to any pool (recommended for custom NPCSpawnEntry that share a pool)</param>
        public override void FinalizeDataHolder(bool addToPool)
        {
            if (Entry == null)
            {
                Entry = NPCMgr.GetEntry(EntryId);
                if (Entry == null)
                {
                    ContentMgr.OnInvalidDBData("{0} had an invalid EntryId.", (object)this);
                    return;
                }
            }

            if (EquipmentId != 0U)
            {
                Equipment = NPCMgr.GetEquipment(EquipmentId);
            }
            if (DisplayIdOverride == 16777215U)
            {
                DisplayIdOverride = 0U;
            }
            base.FinalizeDataHolder(addToPool);
            if (MapId != MapId.End)
            {
                Entry.SpawnEntries.Add(this);
                ArrayUtil.Set(ref NPCMgr.SpawnEntries, SpawnId, this);
                if (addToPool)
                {
                    AddToPoolTemplate();
                }
            }

            if (_eventId != 0)
            {
                uint       id         = (uint)Math.Abs(_eventId);
                WorldEvent worldEvent = WorldEventMgr.GetEvent(id);
                if (worldEvent != null)
                {
                    WorldEventNPC worldEventNpc = new WorldEventNPC
                    {
                        _eventId = _eventId,
                        EventId  = id,
                        Guid     = SpawnId,
                        Spawn    = _eventId > 0
                    };
                    worldEvent.NPCSpawns.Add(worldEventNpc);
                }

                EventId = id;
            }

            foreach (NPCSpawnTypeHandler spawnTypeHandler in Entry.SpawnTypeHandlers)
            {
                if (spawnTypeHandler != null)
                {
                    spawnTypeHandler(this);
                }
            }
        }
Esempio n. 24
0
        public override string ToLink(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null)
        {
            return("an abduction");

            /*string colString = this.GetYearTime(true) + "The " + ordinals[numeral] + " abduction of ";
             * if (abductee != null) colString += abductee.ToLink(path, pov);
             * else colString += "UNKNOWN FIGURE";
             *               return colString + " in " + period.ToLink(path, pov) + " ocurred";*/
        }
Esempio n. 25
0
 public void ShowEventDialog(WorldEvent eventToDisplay,
                             Action <WorldEvent> onDismissal)
 {
     triggeredEvent         = eventToDisplay;
     dialogTitle.text       = triggeredEvent.ComputedTitle;
     dialogDescription.text = triggeredEvent.ComputedDescription;
     onDialogDismissed      = onDismissal;
     gameObject.SetActive(true);
 }
Esempio n. 26
0
        public ActionResult DeleteConfirmed(int id)
        {
            WorldEvent worldEvent = db.WorldEvents.Find(id);

            db.WorldEvents.Remove(worldEvent);
            db.SaveChanges();
            //next line changed from Index to Create
            return(RedirectToAction("Create"));
        }
Esempio n. 27
0
    public static void CreateWorldEvent()
    {
        WorldEvent asset = (WorldEvent)CreateAsset("DoVAlpha/GovernmentsDefault/data/events/", typeof(WorldEvent));

        if (asset != null)
        {
            asset.EventName = "some government";
        }
    }
Esempio n. 28
0
        public override string ToLink(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null)
        {
            if (Name != "")
            {
                return(Name);
            }

            return("(" + StartYear + " - " + EndYear + ")");
        }
Esempio n. 29
0
 public void OnInteractionInput(WorldEvent e)
 {
     Debug.Log("play " + idx % 3);
     if (po[idx % 5] != null)
     {
         po[idx % 5].ParticleObjectPlay(0.5f, 2f, regions[idx % 4].center, regions[idx % 4].area);
     }
     idx++; // po.Length;
     lastEffectTimeStamp = UnixTimeNow();
 }
    private void Create(string eventName, bool repeat, int maxRepeats, string[] preconditionNames,
                        string[] onExecuteNames)
    {
        WorldEvent worldEvent = new WorldEvent(eventName, repeat, maxRepeats);

        worldEvent.RegisterPreconditions(preconditionNames);
        worldEvent.RegisterAction(onExecuteNames);

        worldEvents[eventName] = worldEvent;
    }
Esempio n. 31
0
    public void Open(WorldEvent worldEvent)
    {
        currentWorldEvent = worldEvent;
        Refresh(worldEvent.GetWorldEventData());
        SetButtonActivity();

        isOpened = true;
        gameObject.SetActive(true);
        UIManager.instance.OnUIPanelOpen();
    }
Esempio n. 32
0
 private void AddEvent(WorldEvent newEvent)
 {
     Events.Add(newEvent);
 }
Esempio n. 33
0
 void OnDisable()
 {
     GameManager.worldEvent -= EventManager;
     GameManager.nextTurn -= NextTurn;
 }