/// <summary> /// Occurs when a player tries to pm a other player on the server. /// </summary> /// <param name="cpkt"></param> private void CM_SENDWHISPER(CMSG_SENDWHISPER cpkt) { //HELPER VARIABLES Character target; string user = cpkt.Name.ToUpperInvariant(); string user2 = this.character.Name.ToUpperInvariant(); byte result = 0; Predicate <KeyValuePair <string, byte> > BlacklistOwn = delegate(KeyValuePair <string, byte> pair) { return(pair.Key == user); }; Predicate <KeyValuePair <string, byte> > BlacklistFoo = delegate(KeyValuePair <string, byte> pair) { return(pair.Key == user2); }; //CHECK IF USER IS ONLINE if (LifeCycle.TryGetByName(user, out target)) { if (target._blacklist.FindIndex(BlacklistFoo) > -1) { result = 2; } else if (this.character._blacklist.FindIndex(BlacklistOwn) > -1) { result = 3; } } else { result = 1; } //STRUCTURIZE PACKETS if (result > 0) { SMSG_WHISPERERROR spkt = new SMSG_WHISPERERROR(); spkt.SessionId = this.character.id; spkt.Result = result; this.Send((byte[])spkt); } else { SMSG_SENDWHISPER spkt = new SMSG_SENDWHISPER(); spkt.SessionId = this.character.id; spkt.Name = cpkt.Name; spkt.Message = cpkt.Message; spkt.Result = 1; this.Send((byte[])spkt); SMSG_SENDWHISPER spkt2 = new SMSG_SENDWHISPER(); spkt2.SessionId = target.id; spkt2.Name = this.character.Name; spkt2.Message = cpkt.Message; spkt2.Result = 2; target.client.Send((byte[])spkt2); } }
/// <summary> /// Registers a new friend to your friendlist. /// </summary> /// <param name="cpkt"></param> private void CM_FRIENDLIST_REGISTER(CMSG_FRIENDLIST_REGISTER cpkt) { //HELPER VARIABLES byte result = 0; byte clvl = 0; byte jlvl = 0; byte map = 0; byte job = 0; string nname = cpkt.Name; string name = cpkt.Name.ToUpperInvariant(); //CHECK IF YOU CHOOSE YOURSELF if (character.Name.ToUpperInvariant() == name) { result = 4; } //CHECKS IF THE PLAYER IS ALREADY ADDED else if (character._friendlist.Contains(nname)) { result = 3; } //CHECKS IF YOU DON'T OVERLAP YOUR MAXIMUM BOUNDS else if (character._friendlist.Count >= 50) { result = 2; } //VERIFY IF THE CHARACTER EXISTS else if (!Singleton.Database.VerifyNameExists(name)) { result = 1; } //EVERYTHING IS OKAY else { Character target; Singleton.Database.InsertAsFriend(character.ModelId, nname); this.character._friendlist.Add(nname); if (LifeCycle.TryGetByName(name, out target)) { clvl = target._level; jlvl = target.jlvl; map = target.map; job = target.job; } } //STRUCTURIZE PACKET SMSG_FRIENDLIST_REGISTER spkt = new SMSG_FRIENDLIST_REGISTER(); spkt.Name = nname; spkt.Clvl = clvl; spkt.Jlvl = jlvl; spkt.Job = job; spkt.Map = map; spkt.SessionId = cpkt.SessionId; spkt.Reason = result; this.Send((byte[])spkt); }
private void Page_Loaded(object sender, RoutedEventArgs e) { //unreleased character present this.IsUnreleasedDataPresent = LifeCycle.InstanceOf <SettingService>().GetOrDefault(Setting.ShowUnreleasedData, false); //traveler present this.TravelerElement = LifeCycle.InstanceOf <SettingService>().GetOrDefault(Setting.PresentTravelerElementType, Element.Anemo, Setting.EnumConverter <Element>); foreach (RadioButton radioButton in this.TravelerOptions.Children) { if (ElementHelper.GetElement(radioButton) == this.TravelerElement) { radioButton.IsChecked = true; } } //version Version v = Assembly.GetExecutingAssembly().GetName().Version; this.VersionString = $"DGP.Genshin - version {v.Major}.{v.Minor}.{v.Build} Build {v.Revision}"; //theme Func <object, ApplicationTheme?> converter = n => { if (n == null) { return(null); } return((ApplicationTheme)Enum.Parse(typeof(ApplicationTheme), n.ToString())); }; this.ThemeComboBox.SelectedIndex = LifeCycle.InstanceOf <SettingService>().GetOrDefault(Setting.AppTheme, null, converter) switch { ApplicationTheme.Light => 0, ApplicationTheme.Dark => 1, _ => 2, }; }
public void RegisterType(Type type, LifeCycle lifeCycle = LifeCycle.Transient, RegisterMode mode = RegisterMode.Self, string name = "") { var builder = new ContainerBuilder(); builder.RegisterType(type, mode, name).UseLifeCycle(lifeCycle); builder.Update(_container); }
public void Register <TInterface, TImplementation>(LifeCycle lifeCycle) where TInterface : class where TImplementation : class, TInterface { Register(typeof(TInterface), typeof(TImplementation), lifeCycle, Key.None); }
/// <summary> /// Ctor. /// </summary> /// <param name="serviceType">Type of registered service</param> /// <param name="implementationType">Type og implementator</param> /// <param name="lifeCycle">Life cycle of implementation</param> /// <param name="factory">Factory of service instantiation</param> public ServiceInfo(Type serviceType, Type implementationType, LifeCycle lifeCycle, Delegate factory) { ServiceType = serviceType; ImplementationType = implementationType; LifeCycle = lifeCycle; Factory = factory; }
public static uint GetCurrentStep2(uint CID, uint QID) { Character value; if (LifeCycle.TryGetById(CID, out value)) { List <Saga.Quests.Objectives.ObjectiveList.StepInfo> info; if (value.QuestObjectives.ScenarioSteps.TryGetValue(QID, out info)) { if (info.Count > 0) { return(info[0].StepId); } else { return(0); } } else { return(0); } } return(0); }
/// <summary> /// Adds a quest step to the quests. /// </summary> public static void AddStep(uint CID, uint QID, uint StepID) { Character value; if (LifeCycle.TryGetById(CID, out value)) { List <Saga.Quests.Objectives.ObjectiveList.StepInfo> info; if (value.QuestObjectives.ScenarioSteps.TryGetValue(QID, out info)) { Predicate <Saga.Quests.Objectives.ObjectiveList.StepInfo> FindItem = delegate(Saga.Quests.Objectives.ObjectiveList.StepInfo myInfo) { return(myInfo.Quest == QID && myInfo.StepId == StepID); }; Saga.Quests.Objectives.ObjectiveList.StepInfo stepInfo = info.Find(FindItem); if (stepInfo == null) { info.Add(new Saga.Quests.Objectives.ObjectiveList.StepInfo(1, QID, StepID)); } } else { info = new List <Saga.Quests.Objectives.ObjectiveList.StepInfo>(); info.Add(new Saga.Quests.Objectives.ObjectiveList.StepInfo(1, QID, StepID)); value.QuestObjectives.ScenarioSteps.Add(QID, info); } } }
public static float FindPosition(uint cid, uint questid, float x, float y, float z, byte map) { Character value; if (LifeCycle.TryGetById(cid, out value)) { Predicate <Saga.Quests.Objectives.ObjectiveList.Position> callback = delegate(Saga.Quests.Objectives.ObjectiveList.Position objective) { return(objective.point == new Point(x, y, z) && objective.mapid == map && objective.Quest == questid); }; if (value.QuestObjectives.ScenarioPosition.FindIndex(callback) == -1) { lock (value.QuestObjectives.ScenarioPosition) { value.QuestObjectives.ScenarioPosition.Add( new Saga.Quests.Objectives.ObjectiveList.Position( x, y, z, map, 1000, questid, 0, 0 )); } } if (map == value.map) { return((float)Vector.GetDistance3D(value.Position, new Point(x, y, z))); } else { return(float.MaxValue); } } return(float.MaxValue); }
public static void CompleteQuest(uint cid, uint questid) { Character value; if (LifeCycle.TryGetById(cid, out value)) { QuestBase scenarioQuest = value.QuestObjectives.Quests[3]; if (scenarioQuest != null && scenarioQuest.QuestId == questid) { Predicate <Saga.Quests.Objectives.ObjectiveList.Position> FindPosition = delegate(Saga.Quests.Objectives.ObjectiveList.Position point) { return(point.Quest == questid); }; lock (value.QuestObjectives.ScenarioPosition){ value.QuestObjectives.ScenarioPosition.RemoveAll(FindPosition); } value.QuestObjectives.ScenarioSteps.Remove(questid); value.QuestObjectives.Quests[3] = null; SMSG_SCENARIOCOMPLETE spkt = new SMSG_SCENARIOCOMPLETE(); spkt.Scenario = questid; spkt.SessionId = value.id; value.client.Send((byte[])spkt); Thread.Sleep(3); scenarioQuest.OnFinish(value.id); } } }
public Behavior(Behavior otherBehavior) { Tag = otherBehavior.Tag; Table = otherBehavior.Table; Cycle = new LifeCycle(otherBehavior.Cycle); Properties = new LifeProperties(otherBehavior.Properties); }
public Behavior(BehaviorTag tag) { Tag = tag; Table = new ReactionTable(); Cycle = new LifeCycle(); Properties = new LifeProperties(); }
/// <summary> /// Get's the currentscenariostep /// </summary> public static uint StartEvent(uint cid, uint EventId) { Console.WriteLine("Start event: {0}", EventId); Character value; if (LifeCycle.TryGetById(cid, out value)) { SMSG_SCENARIOEVENTBEGIN spkt = new SMSG_SCENARIOEVENTBEGIN(); spkt.ActorId = value.id; spkt.Event = EventId; value._Event = EventId; Regiontree tree = value.currentzone.Regiontree; foreach (Character regionObject in tree.SearchActors(value, SearchFlags.Characters)) { if (value.currentzone.IsInSightRangeByRadius(value.Position, regionObject.Position)) { spkt.SessionId = regionObject.id; regionObject.client.Send((byte[])spkt); } } while (value._Event > 0) { Thread.Sleep(0); } } return(0); }
public bool Register(Type tDependency, Type tImplementation, LifeCycle lifeCycle = LifeCycle.InstancePerDependency) { if (tImplementation.IsAbstract) { throw new Exception("TImplementation can not be abstract."); } if (tImplementation.GetConstructors().Length != 0) { if (!dependencies.ContainsKey(tDependency)) { dependencies.Add( tDependency, new List <Implementation> { new Implementation(tImplementation, lifeCycle) }); } else { dependencies[tDependency].Add( new Implementation(tImplementation, lifeCycle)); } return(true); } throw new Exception("TImplementation should have at least one public constructor."); }
/// <title>Saga.ClearWaypoints</title> /// <code> /// Saga.ClearWaypoints(cid, QuestID, StepId, State); /// </code> /// <description> /// Removes all waypoints for a the specified quest. /// </description> /// <example> /// function QUEST_STEP_2(cid) /// -- Talk to mischa /// local NPCIndex = 1000; /// local ret = Saga.GetNPCIndex(cid); /// /// Saga.AddWaypoint(cid, QuestID, NPCIndex, -12092, -6490, -8284, 1); /// if ret == NPCIndex then /// Saga.StepComplete(cid, QuestID, 102); /// else /// return -1; /// end /// /// Saga.ClearWaypoints(cid, QuestID); /// return 0; /// end /// </example> public static void ClearWayPoints(uint CID, uint QID) { QuestBase quest; Character value; if (LifeCycle.TryGetById(CID, out value)) { quest = value.QuestObjectives[QID]; Predicate <Saga.Quests.Objectives.ObjectiveList.Waypoint> FindGuidancePoints = delegate(Saga.Quests.Objectives.ObjectiveList.Waypoint objective) { return(objective.Quest == QID); }; if (quest != null) { quest.IsWaypointsCleared = true; } int count = value.QuestObjectives.GuidancePoints.RemoveAll(FindGuidancePoints); if (count > 0) { SMSG_REMOVENAVIGATIONPOINT spkt = new SMSG_REMOVENAVIGATIONPOINT(); spkt.SessionId = value.id; spkt.QuestID = QID; value.client.Send((byte[])spkt); } } }
/// <title>Saga.NpcTakeItem</title> /// <code> /// Saga.NpcTakeItem(cid, QuestID, ItemId, Count); /// </code> /// <description> /// Takes a npc item as with a message that the npc took it. /// </description> /// <example> public static int TakeItem(uint cid, uint itemid, byte count) { Character value; if (LifeCycle.TryGetById(cid, out value)) { //HELPER VARIABLES DEFAULT_FACTORY_ITEMS.ItemInfo info; Singleton.Item.TryGetItem(itemid, out info); //int stackcount = 0; Predicate <Rag2Item> callback = delegate(Rag2Item item) { bool result = item.info.item == itemid; //if (result) stackcount += item.info.max_stack - item.count; return(result); }; //CHECK IF RIGHT AMOUNT OF ITEMS WAS FOUND List <int> FoundItems = value.ITEMS.FindAll(callback); //if (count > stackcount) return -1; //DO THE ACTUAL TAKING int acount = count; foreach (int currentInxdex in FoundItems) { Stackable <Rag2Item> item = value.ITEMS[currentInxdex]; int MinCount = Math.Min(acount, Math.Min(item.Count, info.max_stack)); acount -= MinCount; if ((item.Count -= MinCount) == 0) { value.ITEMS.RemoveAt(currentInxdex); SMSG_DELETEITEM spkt = new SMSG_DELETEITEM(); spkt.Container = 2; spkt.Index = (byte)currentInxdex; spkt.UpdateReason = (byte)ITEMUPDATEREASON.GIVE_TO_NPC; spkt.SessionId = value.id; value.client.Send((byte[])spkt); } else { SMSG_UPDATEITEM spkt = new SMSG_UPDATEITEM(); spkt.Amount = (byte)item.Count; spkt.UpdateReason = (byte)ITEMUPDATEREASON.GIVE_TO_NPC; spkt.UpdateType = 4; spkt.Container = 2; spkt.SessionId = value.id; spkt.Index = (byte)currentInxdex; value.client.Send((byte[])spkt); break; } } return(count); } else { return(-1); } }
public RegisteredEntry(Type AbstractType, Type ConcreteType, LifeCycle lifecycle, string entryName) { this.AbstractType = AbstractType; this.ConcreteType = ConcreteType; this.lifecycle = lifecycle; this.EntryName = entryName; }
public void ChangeAge(LifeCycle lifeCycle) { switch (lifeCycle) { case LifeCycle.Child: LifeStageData = new SeniorData(); break; case LifeCycle.Teen: LifeStageData = new SeniorData(); break; case LifeCycle.Adult: LifeStageData = new SeniorData(); break; case LifeCycle.Senior: LifeStageData = new SeniorData(); break; case LifeCycle.Death: // Kill tamagochi of old age break; } Console.WriteLine($"{_name} is a{LifeStageData.LifeStage} now!"); }
/// <title>Saga.GiveItem</title> /// <code> /// Saga.GiveItem(cid, RewItem, RewItemCount); /// </code> /// <description> /// Gives a certain item and with the specified /// itemcount as part of a quest reward. /// </description> /// <example> ///function QUEST_FINISH(cid) /// -- Gives all rewards /// /// Saga.GiveItem(cid, RewItem1, RewItemCount1 ); /// Saga.GiveZeny(cid, RewZeny); /// Saga.GiveExp(cid, RewCxp, RewJxp, RewWxp); /// return 0; /// end /// </example> public static bool GiveItem(uint cid, uint itemid, byte count) { Character value; if (LifeCycle.TryGetById(cid, out value)) { Rag2Item item; if (Singleton.Item.TryGetItemWithCount(itemid, count, out item)) { int index = value.container.Add(item); if (index > -1) { SMSG_ADDITEM spkt = new SMSG_ADDITEM(); spkt.Container = 2; spkt.SessionId = value.id; spkt.UpdateReason = (byte)ItemUpdateReason.ReceivedAsQuestReward; spkt.SetItem(item, index); value.client.Send((byte[])spkt); return(true); } } } return(false); }
/// <summary> /// Add registration by creating a new object to reference parts /// </summary> /// <param name="from">Type from</param> /// <param name="to">Type to</param> /// <param name="lifeCycle">LifeCycle lifeCycle</param> public void Register(Type from, Type to, LifeCycle lifeCycle = LifeCycle.Transient) { var checkDups = registrations.Where(x => x.From == from).FirstOrDefault(); registrations.Remove(checkDups); registrations.Add(new Register(to, from, lifeCycle)); }
public CreateRegisteredType(Type concreteType, LifeCycle lifeCycle) { ConcreteType = concreteType ?? throw new ArgumentNullException(nameof(concreteType), "You must supply a concrete type."); LifeCycle = lifeCycle; }
public NotifyPointOfSale( LifeCycle lc, Stream <Unit> sClearSale, Fill fi) { Cell <bool> locked = lc.SStart.Map(u => true).OrElse(sClearSale.Map(u => false)).Hold(false); this.SStart = lc.SStart.Gate(locked.Map(l => !l)); this.SEnd = lc.SEnd.Gate(locked); this.FuelFlowing = this.SStart.Map(Maybe.Some).OrElse( this.SEnd.Map(f => Maybe <Fuel> .None)).Hold(Maybe.None); this.FillActive = this.SStart.Map(Maybe.Some).OrElse( sClearSale.Map(f => Maybe <Fuel> .None)).Hold(Maybe.None); this.SBeep = sClearSale; this.SSaleComplete = this.SEnd.Snapshot( this.FuelFlowing.Lift( fi.Price, fi.DollarsDelivered, fi.LitersDelivered, (oFuel, price, dollars, liters) => oFuel.Match( v => Maybe.Some(new Sale(v, price, dollars, liters)), () => Maybe.None))).FilterMaybe(); }
public void Register <T>(Func <T> creator, LifeCycle lifeCycle = LifeCycle.Transient, RegisterMode mode = RegisterMode.Self, string name = "") where T : class { var builder = new ContainerBuilder(); builder.Register <T>(creator, mode, name).UseLifeCycle(lifeCycle); builder.Update(_container); }
/// public IContainer Register <TService, TComp>(string name, LifeCycle lifeCycle) where TService : class where TComp : TService { Registrator.Register(typeof(TComp), new[] { typeof(TService) }, name, lifeCycle); return(this); }
/// <title>Saga.AddWaypoint</title> /// <code> /// Saga.AddWaypoint(cid, QuestID, StepId, State); /// </code> /// <description> /// Adds a waypoint to the quest list. /// (Note it will also activate the npc if it's not yet activated) /// </description> /// <example> /// function QUEST_STEP_2(cid) /// -- Talk to mischa /// local NPCIndex = 1000; /// local ret = Saga.GetNPCIndex(cid); /// /// Saga.AddWaypoint(cid, QuestID, NPCIndex, -12092, -6490, -8284, 1); /// if ret == NPCIndex then /// Saga.StepComplete(cid, QuestID, 102); /// else /// return -1; /// end /// /// Saga.ClearWaypoints(cid, QuestID); /// return 0; /// end /// </example> public static void AddWayPoint(uint cid, uint QID, uint stepid, byte substepid, uint npcType) { Character Character; if (LifeCycle.TryGetById(cid, out Character)) { //Substep - 1; substepid--; //Find the substep Predicate <Saga.Quests.Objectives.ObjectiveList.SubStep> FindSubstep = delegate(Saga.Quests.Objectives.ObjectiveList.SubStep objective) { return(objective.Quest == QID && objective.StepId == stepid && objective.SubStepId == substepid); }; Predicate <Saga.Quests.Objectives.ObjectiveList.Waypoint> FindWaypoint = delegate(Saga.Quests.Objectives.ObjectiveList.Waypoint objective) { return(objective.Quest == QID && objective.StepId == stepid && objective.NpcId == npcType); }; //Get substep list List <Saga.Quests.Objectives.ObjectiveList.SubStep> Substeps = Character.QuestObjectives.Substeps; //Add waypoint List <Saga.Quests.Objectives.ObjectiveList.Waypoint> Waypoints = Character.QuestObjectives.GuidancePoints; //Add substeps int index = Substeps.FindIndex(FindSubstep); if (index == -1) { int index2 = Waypoints.FindIndex(FindWaypoint); if (index2 == -1) { Substeps.Add(new Saga.Quests.Objectives.ObjectiveList.SubStep(substepid, false, 0, 1, QID, stepid)); Waypoints.Add(new Saga.Quests.Objectives.ObjectiveList.Waypoint(npcType, QID, stepid, substepid)); Regiontree tree = Character.currentzone.Regiontree; foreach (MapObject a in tree.SearchActors(Character, SearchFlags.Npcs)) { BaseMob mob = a as BaseMob; if (a.ModelId == npcType) { if (mob != null) { Common.Actions.UpdateIcon(Character, mob); } } } } } } }
/// <summary> /// Initializes a new instance of the <see cref="Process"/> class. /// </summary> /// <param name="bucket">the bucket.</param> /// <param name="parent">the parent job.</param> /// <param name="current">the current job.</param> public Process(IBucket bucket, IProcess parent, IWorkUnit current) { this.bucket = bucket; this.Parent = parent?.Current; this.Route = $"{parent?.Route}{current.Name}"; this.Current = current; this.state = LifeCycle.Created; }
public BindingAttribute( Type typeToResolve, LifeCycle lifeCycle = LifeCycle.Default, params Type[] injectInto ) : this(typeToResolve, lifeCycle, injectInto, null) { }
public RegisteredUnityObject(Type type, Type concrete, LifeCycle lifeCycle, GameObject gObject) : base(type, concrete, lifeCycle) { TypeToResolve = type; ConcreteType = concrete; LifeCycle = lifeCycle; Instance = gObject; }
/// <summary> /// Initializes the newly created <c>Actor</c>. /// </summary> protected Actor() { var maybeEnvironment = ActorFactory.ThreadLocalEnvironment.Value; LifeCycle = new LifeCycle(maybeEnvironment ?? new TestEnvironment(), new Evictable(this)); ActorFactory.ThreadLocalEnvironment.Value = null; CompletesImpl = new ResultCompletes <object>(); }
/// <summary> /// Initializes a new instance of the <see cref="MailBox"/> class. /// </summary> /// <param name="collector">the collector.</param> public MailBox(ICollector collector) { this.state = LifeCycle.Running; this.collector = collector; this.Id = Guid.NewGuid(); this.locker = new object(); this.messages = new Queue <IMessage>(); }
public DependencyObject(Type resolveType, Type concreteType, LifeCycle lifeCycle, IList<Type> dependencyList) { Instance = null; ResolveType = resolveType; ConcreteType = concreteType; LifeCycle = lifeCycle; DependencyList = dependencyList; }
/// <summary> /// Need to build objects and set types /// </summary> public Register(Type to, Type from, LifeCycle lifeCycle) { To = to; From = from; LifeCycle = lifeCycle; }
public RegisterInContainerAttribute(LifeCycle life_cycle) { this.life_cycle = life_cycle; }
public RegisteredObject(Type typeToResolve, Type concreteType, LifeCycle lifeCycle) { TypeToResolve = typeToResolve; ConcreteType = concreteType; LifeCycle = lifeCycle; }
public static LifeCycle CreateLifeCycle(string ID, string condition) { LifeCycle lifeCycle = new LifeCycle(); lifeCycle.Id = ID; lifeCycle.Condition = condition; return lifeCycle; }
public void AddToLifeCycles(LifeCycle lifeCycle) { base.AddObject("LifeCycles", lifeCycle); }
public RegisteredObject(Type typeToResolve, Func<IContainer, object> instanceExpression, LifeCycle lifeCycle) { TypeToResolve = typeToResolve; InstanceExpression = instanceExpression; LifeCycle = lifeCycle; }