Ejemplo n.º 1
0
 void RemoveAll(StructureMaster master, RemoveHandler rplayer)
 {
     foreach (StructureComponent comp in (HashSet <StructureComponent>)structureComponents.GetValue(master))
     {
         TakeDamage.KillSelf(comp.GetComponent <IDMain>());
     }
 }
Ejemplo n.º 2
0
 void TryToRemove(TakeDamage takedamage, RemoveHandler rplayer)
 {
     cachedStructure  = takedamage.GetComponent <StructureComponent>();
     cachedDeployable = takedamage.GetComponent <DeployableObject>();
     if (cachedStructure != null && cachedStructure._master != null)
     {
         cachedMaster = cachedStructure._master;
         if (!canRemove(rplayer, cachedMaster.ownerID.ToString()))
         {
             SendReply(rplayer.playerclient.netUser, noRemoveAccess); return;
         }
         if (rplayer.removeType == "all")
         {
             RemoveAll(cachedMaster, rplayer);
         }
         else
         {
             SimpleRemove(cachedStructure, rplayer);
         }
     }
     else if (cachedDeployable != null)
     {
         if (!canRemove(rplayer, cachedDeployable.ownerID.ToString()))
         {
             SendReply(rplayer.playerclient.netUser, noRemoveAccess); return;
         }
         DeployableRemove(cachedDeployable, rplayer);
     }
 }
Ejemplo n.º 3
0
 public Octree(T space, AddHandler addHandler, RemoveHandler removeHandler, SearchHandler searchHandler, SetRootHandler setRootHandler, RemoveAllHandler removeAllHandler)
 {
     this.space = space;
     this.AddHandlerCallback       = addHandler;
     this.RemoveHandlerCallback    = removeHandler;
     this.SearchHandlerCallback    = searchHandler;
     this.SetRootHandlerCallback   = setRootHandler;
     this.RemoveAllHandlerCallback = removeAllHandler;
 }
        static ObjectManager()
        {
            mAddHandler = new AddHandler(addImpl);
            UnmanagedObjectManager_setAdd(mAddHandler);
            mRemoveHandler = new RemoveHandler(removeImpl);
            UnmanagedObjectManager_setRemove(mRemoveHandler);

            mObjectMap = new Dictionary<IntPtr, Holder>();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// End the tracking of the current target.
 /// </summary>
 protected void endTrackingTarget()
 {
     if (_tracked_target != null)
     {
         // Remove our handlers from the sprite we were tarcking.
         _tracked_target.Removed -= _tracked_target_on_removed_handler_ref;
         _tracked_target_on_removed_handler_ref = null;
         _tracked_target = null;
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// The method will execute the given command with its arguments.
 /// </summary>
 /// <param name="args">The arguments.</param>
 /// <param name="result">if set to <c>true</c> [result].</param>
 /// <returns>System.String.</returns>
 /// The command's arguments.
 /// The result of the command success/failure.
 public string Execute(string[] args, out bool result)
 {
     if (GetCongigCommand.handlers.Contains(args[0]))
     {
         GetCongigCommand.handlers.Remove(args[0]);
     }
     RemoveHandler?.Invoke(this, args[0]);
     result = true;
     return(args[0]);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor for SettingsViewModel class
        /// </summary>
        /// <param name="model">an instance of SettingsModel</param>
        public SettingsViewModel(SettingsModel model)
        {
            Handlers               = new ObservableCollection <string>();
            this.model             = model;
            model.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                NotifyPropertyChanged(e.PropertyName);
            };

            this.model.Handlers.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e)
            {
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    foreach (string item in e.NewItems)
                    {
                        if (string.IsNullOrWhiteSpace(item))
                        {
                            continue;
                        }
                        App.Current.Dispatcher.Invoke(delegate
                        {
                            Handlers.Add(item);
                        });
                    }
                    NotifyPropertyChanged("Handlers");
                    App.Current.Dispatcher.Invoke(delegate
                    {
                        RemoveHandler.RaiseCanExecuteChanged();
                    });
                    break;

                case NotifyCollectionChangedAction.Remove:
                    foreach (string item in e.OldItems)
                    {
                        App.Current.Dispatcher.Invoke(delegate
                        {
                            Handlers.Remove(item);
                        });
                    }
                    NotifyPropertyChanged("Handlers");
                    App.Current.Dispatcher.Invoke(delegate
                    {
                        RemoveHandler.RaiseCanExecuteChanged();
                    });
                    break;

                default:
                    break;
                }
            };
            Handlers      = new ObservableCollection <string>();
            RemoveHandler = new DelegateCommand <object>(this.OnRemove, this.CanRemove);
        }
Ejemplo n.º 8
0
 void DeployableRemove(DeployableObject deployable, RemoveHandler rplayer)
 {
     if (!canRemoveDeployable(deployable, rplayer.removeType))
     {
         SendReply(rplayer.playerclient.netUser, noRemoveAccess); return;
     }
     if (canRefund)
     {
         TryRefund(deployableCloneToGood[deployable.gameObject.name], rplayer);
     }
     TakeDamage.KillSelf(deployable.GetComponent <IDMain>());
 }
Ejemplo n.º 9
0
        void SimpleRemove(StructureComponent structurecomponent, RemoveHandler rplayer)
        {
            object canremove = canRemoveStructure(structurecomponent, rplayer.removeType);

            if (canremove is string)
            {
                SendReply(rplayer.playerclient.netUser, canremove as string); return;
            }
            if (canRefund)
            {
                TryRefund(structureCloneToGood[structurecomponent.gameObject.name], rplayer);
            }
            TakeDamage.KillSelf(structurecomponent.GetComponent <IDMain>());
        }
Ejemplo n.º 10
0
        protected IClientSprite _tracked_target = null;  // Target the missile is tracking.


        /// <summary>
        /// Start tracking the given target.
        /// </summary>
        /// <param name="tracked_target"></param>
        protected void startTrackingTarget(IClientSprite tracked_target)
        {
            // Check if we are already tracking a target.
            if (_tracked_target != null)
            {
                throw new InvalidOperationException("startTrackingTarget: need to end tracking before tracking a new target.");
            }

            if (tracked_target != null)
            {
                _tracked_target = tracked_target;
                _tracked_target_on_removed_handler_ref = new RemoveHandler(tracked_targeted_SpriteRemoveHandler);
                _tracked_target.Removed += _tracked_target_on_removed_handler_ref;
            }
        }
Ejemplo n.º 11
0
 void ActivateDeactivateRemover(NetUser netuser, string ttype, float secs, int length)
 {
     cachedRemoveHandler = netuser.playerClient.GetComponent <RemoveHandler>();
     if (cachedRemoveHandler != null && length == 0)
     {
         DeactivateRemover(netuser); return;
     }
     if (cachedRemoveHandler == null)
     {
         cachedRemoveHandler = netuser.playerClient.gameObject.AddComponent <RemoveHandler>();
     }
     cachedRemoveHandler.deactivateTime = Time.realtimeSinceStartup + secs;
     cachedRemoveHandler.removeType     = ttype;
     cachedRemoveHandler.Activate();
 }
Ejemplo n.º 12
0
        private void Source_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems != null)
            {
                var index = e.NewStartingIndex;

                foreach (var item in e.NewItems.Cast <TFrom>())
                {
                    Target.Insert(index++, Mapper(item));
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Move)
            {
                throw new NotImplementedException();
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems != null)
            {
                for (int i = 0; i < e.OldItems.Count; i++)
                {
                    var index = e.OldStartingIndex + i;

                    var item = Target[index];
                    Target.RemoveAt(index);

                    RemoveHandler?.Invoke(item);
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                throw new NotImplementedException();
            }
            else if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                foreach (var item in Target)
                {
                    RemoveHandler?.Invoke(item);
                }

                Target.Clear();

                foreach (var item in Source)
                {
                    Target.Add(Mapper(item));
                }
            }
        }
Ejemplo n.º 13
0
 bool canRemove(RemoveHandler rplayer, string ownerid)
 {
     if (rplayer.removeType == "admin" || rplayer.removeType == "all")
     {
         return(true);
     }
     else if (rplayer.removeType == "normal" && rplayer.userid == ownerid)
     {
         return(true);
     }
     else if (useShare)
     {
         var share = Share?.Call("isSharing", ownerid, rplayer.userid);
         if (share is bool)
         {
             return((bool)share);
         }
     }
     return(false);
 }
Ejemplo n.º 14
0
 void TryRefund(string gameobjectname, RemoveHandler rplayer)
 {
     if (!refundList.ContainsKey(gameobjectname))
     {
         return;
     }
     foreach (object ingredients in (List <object>)refundList[gameobjectname])
     {
         cachedListObject = ingredients as List <object>;
         if (cachedListObject == null || cachedListObject.Count == 0)
         {
             continue;
         }
         if (displaynameToDataBlock.ContainsKey(cachedListObject[0].ToString().ToLower()))
         {
             rplayer.inventory.AddItemAmount(displaynameToDataBlock[cachedListObject[0].ToString().ToLower()], Convert.ToInt32(cachedListObject[1]));
             Rust.Notice.Inventory(rplayer.playerclient.netPlayer, string.Format("{0} x {1}", cachedListObject[0].ToString(), cachedListObject[1].ToString()));
         }
     }
 }
Ejemplo n.º 15
0
 public string Execute(string[] args, out bool result)
 {
     RemoveHandler?.Invoke(this, args[0]);
     result = true;
     return(args[0]);
 }
Ejemplo n.º 16
0
 public static Closure Create(AccessContext parentContext, RemoveHandler action, AccessContextItem item)
 {
     return new RemoveClosure(parentContext, action, item);
 }
Ejemplo n.º 17
0
 internal RemoveClosure(AccessContext parentContext, RemoveHandler action, AccessContextItem item) : base(parentContext)
 {
     _execute = action;
     _arg0 = item;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// raise the RemoveHandler event if it has already asigned
 /// it is useful when reading this data is requested before the end of writing,
 /// but because of an exception, the data is removed
 /// if a thread waits for completion of writing, cancel the thread
 /// </summary>
 public void Remove()
 {
     RemoveHandler?.Invoke(this, new EventArgs());
 }
Ejemplo n.º 19
0
        /// <summary>
        /// the constructor.
        /// </summary>
        private ModelCommunication()
        {
            ///getting a tcpClient instance.
            client = TcpClientChannel.GetInstance();
            //if not already connected then connect.
            if (!TcpClientChannel.connected)
            {
                try
                {
                    //connecting to the server and setting the connected boolean to true.
                    TcpClientChannel.Connect(8000);
                    connected = true;
                }
                catch (Exception)
                {
                    //connection failed.
                    connected = false;
                }
            }
            //If we connected we will continue
            if (TcpClientChannel.connected)
            {
                try
                {
                    Task t = new Task(() =>
                    {
                        //Receiving messages.
                        while (true)
                        {
                            MessageToClient message;
                            //getting all things that relate to the message.
                            try
                            {
                                message = client.recieveMessage();
                            } catch (Exception)
                            {
                                connected = false;
                                return;
                            }
                            int id          = message.TypeMessage;
                            string content  = message.Content;
                            bool allClients = message.AllClients;
                            //Check to who transfer the message
                            if (id == (int)SendClientEnum.AddLog)
                            {
                                AddLog?.Invoke(this, content);
                            }
                            if (id == (int)SendClientEnum.RemoveHandler)
                            {
                                RemoveHandler?.Invoke(allClients, content);
                            }

                            if (id == (int)SendClientEnum.GetConfig)
                            {
                                GetConfig?.Invoke(this, content);
                            }

                            if (id == (int)SendClientEnum.GetLogs)
                            {
                                GetLogs?.Invoke(this, content);
                            }
                        }
                    });
                    t.Start();
                }
                catch (Exception) {
                    connected = false;
                }
            }
        }
Ejemplo n.º 20
0
 public override RemoveHandler RegisterProbeSignalChange(ProbeSignalChangeHandler Callback)
 {
     this._ProbeSignalChange += Callback;
     if (this._ProbeSignalChange != null && this._RemoveSignalChange == null)
     {
         Probe probe = this._Probe;
         this._RemoveSignalChange = probe.RegisterSignalChange(delegate(ProbeSignal Signal, bool Value)
         {
             bool handled = false;
             this._ProbeSignalChange(probe, Signal, Value, ref handled);
         });
     }
     return delegate
     {
         this._ProbeSignalChange -= Callback;
         if (this._ProbeSignalChange == null && this._RemoveSignalChange != null)
         {
             this._RemoveSignalChange();
             this._RemoveSignalChange = null;
         }
     };
 }
Ejemplo n.º 21
0
 internal RemoveClosure(AccessContext parentContext, RemoveHandler action, AccessContextItem item) : base(parentContext)
 {
     _execute = action;
     _arg0    = item;
 }
Ejemplo n.º 22
0
 public static Closure Create(AccessContext parentContext, RemoveHandler action, AccessContextItem item)
 {
     return(new RemoveClosure(parentContext, action, item));
 }
Ejemplo n.º 23
0
 internal Event(RemoveHandler removeHandler, EventKey key = null)
 {
     RemoveHandler = removeHandler;
     Key           = key;
 }
Ejemplo n.º 24
0
 private void removeExecute()
 {
     RemoveHandler?.Invoke(this);
 }