コード例 #1
0
ファイル: StructureMaster.cs プロジェクト: Virobeast2/RCLIENT
 protected void AppendStructureComponent(StructureComponent comp, bool nobind)
 {
     if ((comp.type == StructureComponent.StructureComponentType.Foundation) && (this._materialType == StructureMaterialType.UNSET))
     {
         this.SetMaterialType(comp.GetMaterialType());
     }
     this._structureComponents.Add(comp);
     this.AddCompPositionEntry(comp);
     this.GenerateLinkForComp(comp);
     this.RecalculateStructureLinks();
     this.MarkBoundsDirty();
     if (!nobind)
     {
         try
         {
             comp.OnOwnedByMasterStructure(this);
         }
         catch (Exception exception)
         {
             Debug.LogError(exception);
         }
     }
     if (this._structureComponents.Count == 1)
     {
         g_StructuresWithBounds.Add(this);
     }
     if (this.meshBatchTargetGraphical != null)
     {
         foreach (MeshBatchInstance instance in comp.GetComponentsInChildren <MeshBatchInstance>(true))
         {
             instance.graphicalTarget = this.meshBatchTargetGraphical;
         }
     }
 }
コード例 #2
0
 public static void EntityHurt(object entity, ref DamageEvent e)
 {
     try
     {
         HurtEvent hurtEvent = new HurtEvent(ref e, new Entity(entity));
         if (Hooks.decayList.Contains(entity))
         {
             hurtEvent.IsDecay = true;
         }
         if (hurtEvent.Entity.IsStructure() && !hurtEvent.IsDecay)
         {
             StructureComponent structureComponent = entity as StructureComponent;
             if (structureComponent.IsType(StructureComponent.StructureComponentType.Ceiling) || structureComponent.IsType(StructureComponent.StructureComponentType.Foundation) || structureComponent.IsType(StructureComponent.StructureComponentType.Pillar))
             {
                 hurtEvent.DamageAmount = 0f;
             }
         }
         TakeDamage takeDamage = hurtEvent.Entity.GetTakeDamage();
         takeDamage.health += hurtEvent.DamageAmount;
         if (Hooks.OnEntityHurt != null)
         {
             Hooks.OnEntityHurt(hurtEvent);
         }
         Zone3D zone3D = Zone3D.GlobalContains(hurtEvent.Entity);
         if ((zone3D == null || !zone3D.Protected) && hurtEvent.Entity.GetTakeDamage().health - hurtEvent.DamageAmount > 0f)
         {
             TakeDamage takeDamage2 = hurtEvent.Entity.GetTakeDamage();
             takeDamage2.health -= hurtEvent.DamageAmount;
         }
     }
     catch (Exception ex)
     {
         Helper.LogError(ex.ToString(), true);
     }
 }
コード例 #3
0
 /// <summary>
 /// Validates if a given component is boolean data type.
 /// </summary>
 /// <param name="exp">The expression source to throw an exception.</param>
 /// <param name="exp">The expression source to throw an exception.</param>
 /// <param name="component">The component to validate.</param>
 private void ValdiateComponent(IExpression exp, StructureComponent component)
 {
     if (!component.ValueDomain.DataType.In(BasicDataType.Boolean, BasicDataType.None))
     {
         throw new VtlOperatorError(exp, this.Name, "Expected boolean value.");
     }
 }
コード例 #4
0
        public IDataStructure GetOutputStructure(IExpression expression)
        {
            IExpression expr1 = expression.OperandsCollection.ToArray()[0];
            IExpression expr2 = expression.Operands["ds_2"];

            IDataStructure structure = expr1.Structure.GetCopy();

            if (this.Keyword == "Standard" || (this.Keyword == "DatasetClause" && expression.ParentExpression?.OperatorSymbol == "datasetClause"))
            {
                StructureComponent component = expr2.Structure.Components[0];

                this.TransformStructrure(structure, component);
                if (structure.IsSingleComponent)
                {
                    throw new VtlOperatorError(expression, this.Name, $"Expected dataset as first parameter.");
                }
                structure.Measures[0].BaseComponentName = component.BaseComponentName;

                if (expr1.OperatorSymbol == "join")
                {
                    this.RemoveAliases(structure);
                }
            }
            else if (this.Keyword.In("Component", "DatasetClause"))
            {
                structure = expr2.Structure.GetCopy();
                expr2.Structure.DatasetName = structure.DatasetName;
            }
            else
            {
                throw new VtlOperatorError(expression, this.Name, $"Unknown operator keyword: {this.Keyword}");
            }

            return(structure);
        }
コード例 #5
0
        public IDataStructure GetOutputStructure(IExpression expression)
        {
            IExpression expr1 = expression.OperandsCollection.ToArray()[0];
            IExpression expr2 = expression.OperandsCollection.ToArray()[1];

            if (expr1.IsScalar || expr2.IsScalar)
            {
                throw new VtlOperatorError(expression, this.Name, "Expeceted 2 datasets.");
            }

            if (expr1.Structure.Identifiers.Count > expr2.Structure.Identifiers.Count)
            {
                throw new VtlOperatorError(expression, this.Name, "Second dataset's identifiers number must be greater or equal to identifiers number of first dataset's.");
            }

            if (expression.CurrentJoinExpr != null)
            {
                return(this._dsResolver("bool_var", ComponentType.Measure, BasicDataType.Boolean));
            }

            IDataStructure     structure = expr1.Structure.GetCopy().WithAttributesOf(expr2.Structure);
            StructureComponent measure   = structure.Measures[0];

            structure.Measures.Clear();
            structure.Measures.Add(measure);
            structure.Measures[0].ComponentName     = "bool_var";
            structure.Measures[0].ValueDomain       = new ValueDomain(BasicDataType.Boolean);
            structure.Measures[0].BaseComponentName = expr1.Structure.GetCopy().Measures[0].ComponentName;

            return(structure);
        }
コード例 #6
0
        /// <summary>
        /// Visits an "apply" branch of a "join" operator expression and renders measures for the TSQL join select query.
        /// </summary>
        /// <param name="applyBranch">The "apply" branch of a "join" operator which parameters shall be used to render.</param>
        /// <param name="measure">The selected measure with the old name to assign in the translated code.</param>
        /// <param name="renamedMeasure">The selected measure with the new name to assign in the translated code.</param>
        /// <returns>The TSQL translated code with measures.</returns>
        private string RenderApplyMeasures(IExpression applyBranch, StructureComponent measure, StructureComponent renamedMeasure)
        {
            string result = this._opRendererResolver(applyBranch.OperatorSymbol).Render(applyBranch, measure);

            string leftParenthesis  = string.Empty;
            string rightParenthesis = string.Empty;

            if (applyBranch.ExpressionText.First() == '(' && applyBranch.ExpressionText.Last() == ')')
            {
                leftParenthesis  = "(";
                rightParenthesis = ")";
            }

            result = $"{leftParenthesis}{result}{rightParenthesis},";
            if (result.Split(',')[0].Length != 2 || result.Split(',')[0].Split('.')[1] != renamedMeasure.ComponentName)
            {
                result = result.Remove(result.Length - 1); // removement of ","
                if (applyBranch.CurrentJoinExpr.Operands.ContainsKey("over"))
                {
                    result += this._opRendererResolver("over").Render(applyBranch.CurrentJoinExpr.Operands["over"]);
                }
                result += $" AS {renamedMeasure.ComponentName},";
            }

            return(result);
        }
コード例 #7
0
        public string Render(IExpression expr, StructureComponent component = null)
        {
            if (!expr.IsScalar && component == null)
            {
                return(this._opRendererResolver("overall").Render(expr, component));
            }

            StringBuilder result      = new StringBuilder();
            IExpression   datasetExpr = expr.OperandsCollection.ToArray()[0];
            string        datasetName = this._opRendererResolver(datasetExpr.OperatorSymbol).Render(datasetExpr);
            string        measureName = component.ComponentName.GetNameWithoutAlias();

            result.AppendLine($"(SELECT SUM({measureName}) FROM (");
            result.AppendLine($"SELECT {measureName} FROM {datasetName}");
            result.AppendLine($"WHERE");

            foreach (StructureComponent identifier in expr.Structure.Identifiers)
            {
                string symbol = "=";
                if (identifier.ValueDomain.DataType.In(BasicDataType.Time, BasicDataType.Date, BasicDataType.TimePeriod))
                {
                    symbol = "<=";
                }
                result.AppendLine($"{identifier.ComponentName} {symbol} ds.{identifier.ComponentName} AND");
            }

            result = new StringBuilder(result.ToString().Remove(result.ToString().Length - 6)); // removement of " AND\n"
            result.Append(") AS t)");

            return(result.ToString());
        }
コード例 #8
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);
     }
 }
コード例 #9
0
        public string Render(IExpression expr, StructureComponent component = null)
        {
            StringBuilder sb = new StringBuilder();

            IExpression expr1 = expr.Operands["ds_1"];
            IExpression expr2 = expr.Operands["ds_2"];

            string name = expr1.ExpressionText;

            if (expr.CurrentJoinExpr.Structure.Components.FirstOrDefault(comp => comp.BaseComponentName == name) == null)
            {
                return(string.Empty); // no component in a result structure
            }
            if (expr.CurrentJoinExpr.Operands.ContainsKey("rename"))
            {
                StructureComponent renameComp = expr.CurrentJoinExpr.Operands["rename"].Structure.Components.LastOrDefault(comp => comp.BaseComponentName == name);
                if (renameComp != null)
                {
                    name = renameComp.ComponentName;
                }
            }

            sb.AppendLine($"{this._opRendererResolver(expr2.OperatorSymbol).Render(expr2, component)} AS {name},");
            return(sb.ToString());
        }
コード例 #10
0
 public void Destroy()
 {
     try
     {
         if (this.IsDeployableObject())
         {
             this.GetObject <DeployableObject>().OnKilled();
         }
         else if (this.IsStructure())
         {
             StructureComponent comp = this.GetObject <StructureComponent>();
             comp._master.RemoveComponent(comp);
             comp._master = null;
             this.GetObject <StructureComponent>().StartCoroutine("DelayedKill");
         }
     }
     catch (Exception)
     {
         if (this.IsDeployableObject())
         {
             NetCull.Destroy(this.GetObject <DeployableObject>().networkViewID);
         }
         else if (this.IsStructure())
         {
             NetCull.Destroy(this.GetObject <StructureComponent>().networkViewID);
         }
     }
 }
コード例 #11
0
        public IDataStructure GetOutputStructure(IExpression expression)
        {
            IDataStructure dataStructure = this._dsResolver();

            foreach (IExpression expr in expression.OperandsCollection)
            {
                StructureComponent currentComp = expr.Structure.GetCopy().Components[0];

                if (!expr.IsScalar)
                {
                    throw new VtlOperatorError(expression, this.Name, "Expected scalar expression.");
                }
                if (expression.ParentExpression == null || !expression.ParentExpression.OperatorSymbol.In("check_datapoint", "check_hierarchy", "check"))
                {
                    foreach (StructureComponent component in dataStructure.Components)
                    {
                        if (!currentComp.ValueDomain.DataType.EqualsObj(component.ValueDomain.DataType))
                        {
                            throw new VtlOperatorError(expression, this.Name, "Data types of all items of collection must be the same.");
                        }
                    }
                }

                dataStructure.Measures.Add(currentComp);
            }

            return(dataStructure);
        }
        public string Render(IExpression expr, StructureComponent component = null)
        {
            string opSymbol = expr.OperatorSymbol;
            string compName = expr.OperandsCollection.ToArray()[0].OperatorSymbol != null?
                              this._opRendererResolver(expr.OperandsCollection.ToArray()[0].OperatorSymbol).Render(expr.OperandsCollection.ToArray()[0]) :
                                  string.Empty;

            if (compName != string.Empty && component != null)
            {
                compName += $".{component.ComponentName}";
            }

            string over = string.Empty;

            if (expr.Operands.ContainsKey("over"))
            {
                over = this._opRendererResolver("over").Render(expr.Operands["over"]);
            }

            if (opSymbol == "ratio_to_report" &&
                ((component != null && component.ValueDomain.DataType.In(BasicDataType.Integer, BasicDataType.Number)) ||
                 (component == null && expr.OperandsCollection.ToArray()[0].Structure.Components[0].ValueDomain.DataType.In(BasicDataType.Integer, BasicDataType.Number))))
            {
                return($"CAST({compName} AS DECIMAL(28,9)) / SUM({compName}){over}");
            }

            return($"{opSymbol.ToUpper()}({compName}){over}");
        }
コード例 #13
0
        public string Render(IExpression expr, StructureComponent component = null)
        {
            if (!expr.IsScalar && !expr.IsApplyComponent && component == null)
            {
                return(this._opRendererResolver("overall").Render(expr, component));
            }

            IExpression expr1 = expr.OperandsCollection.ToArray()[0];
            IExpression expr2 = expr.OperandsCollection.ToArray()[1];

            string op1 = this._opRendererResolver(expr1.OperatorSymbol).Render(expr1, !expr.IsApplyComponent ? component : expr1.Structure.Measures[0]);
            string op2 = this._opRendererResolver(expr2.OperatorSymbol).Render(expr2, !expr.IsApplyComponent ? component : expr2.Structure.Measures[0]);

            string result = string.Empty;
            string symbol = expr.OperatorSymbol;

            if (symbol == "<>")
            {
                symbol = "!=";
            }

            result = $"{op1} {symbol} {op2}";
            if (expr1.Structure.Components[0].ValueDomain.DataType == BasicDataType.String && expr2.Structure.Components[0].ValueDomain.DataType == BasicDataType.String)
            {
                result += " COLLATE Latin1_General_BIN"; // TODO
            }
            if (!expr.ParamSignature.In("filter", "having") &&
                (expr.ParentExpression == null || (!expr.ParentExpression.OperatorSymbol.In("and", "or", "xor", "not") && !expr.ParentExpression.ParamSignature.In("if", "subspace"))) &&
                expr.ContainingSchema.Rulesets.FirstOrDefault(ruleset => ruleset.RulesCollection.Contains(expr.GetFirstAncestorExpr() ?? expr)) == null)
            {
                result = $"IIF({op1} IS NULL OR {op2} IS NULL, NULL,\nIIF({result}, 1, 0))";
            }

            return(result);
        }
コード例 #14
0
        /// <summary>
        /// Precesses renaming operations at a given data structure.
        /// </summary>
        /// <param name="structure">The data structure.</param>
        /// <param name="renameExpr">The rename expression.</param>
        private void ProcessRenameClause(IDataStructure structure, IExpression renameExpr)
        {
            foreach (StructureComponent identifier in renameExpr.Structure.Identifiers)
            {
                StructureComponent comp = structure.Identifiers.FirstOrDefault(id => id.BaseComponentName == identifier.BaseComponentName);
                comp.ComponentName = identifier.ComponentName;
            }

            foreach (StructureComponent measure in renameExpr.Structure.Measures)
            {
                StructureComponent comp = structure.Measures.FirstOrDefault(me => me.BaseComponentName == measure.BaseComponentName);
                comp.ComponentName = measure.ComponentName;
            }

            foreach (StructureComponent attribute in renameExpr.Structure.ViralAttributes)
            {
                StructureComponent comp = structure.ViralAttributes.FirstOrDefault(at => at.BaseComponentName == attribute.BaseComponentName);
                comp.ComponentName = attribute.ComponentName;
            }

            foreach (StructureComponent attribute in renameExpr.Structure.NonViralAttributes)
            {
                StructureComponent comp = structure.NonViralAttributes.FirstOrDefault(at => at.BaseComponentName == attribute.BaseComponentName);
                comp.ComponentName = attribute.ComponentName;
            }
        }
コード例 #15
0
ファイル: AntiGlitch.cs プロジェクト: wilddip/Oxide2Plugins
        void OnStructurePlaced(StructureComponent component, IStructureComponentItem structureComponentItem)
        {
            var structurecheck = component.gameObject.AddComponent <StructureCheck>();

            structurecheck.owner  = structureComponentItem.character;
            structurecheck.radius = 0f;
            if ((antiPillarStash || antiPillarBarricade) && component.IsPillar())
            {
                structurecheck.radius = 0.2f;
            }
            else if (antiFoundationGlitch && (component.type == StructureComponent.StructureComponentType.Foundation))
            {
                structurecheck.radius      = 3.0f;
                structurecheck.position.y += 2f;
            }
            else if (component.type == StructureComponent.StructureComponentType.Ramp)
            {
                if (antiRampStack)
                {
                    if (MeshBatchPhysics.Raycast(structurecheck.position + Vector3ABitUp, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
                    {
                        if (cachedhitInstance != null)
                        {
                            cachedComponent = cachedhitInstance.physicalColliderReferenceOnly.GetComponent <StructureComponent>();
                            if (cachedComponent.type == StructureComponent.StructureComponentType.Foundation || cachedComponent.type == StructureComponent.StructureComponentType.Ceiling)
                            {
                                var weight = getweight.GetValue(cachedComponent._master) as Dictionary <StructureComponent, HashSet <StructureComponent> >;
                                int ramps  = 0;
                                if (weight.ContainsKey(cachedComponent))
                                {
                                    foreach (StructureComponent structure in weight[cachedComponent])
                                    {
                                        if (structure.type == StructureComponent.StructureComponentType.Ramp)
                                        {
                                            ramps++;
                                        }
                                    }
                                }
                                if (ramps > rampstackMax)
                                {
                                    TakeDamage.KillSelf(component.GetComponent <IDMain>());
                                    if (structurecheck.owner != null && structurecheck.owner.playerClient != null)
                                    {
                                        ConsoleNetworker.SendClientCommand(structurecheck.owner.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("You are not allowed to stack more than {0} ramps", rampstackMax.ToString())));
                                    }
                                    timer.Once(0.01f, () => GameObject.Destroy(structurecheck));
                                    return;
                                }
                            }
                        }
                    }
                }
                if (antiRampGlitch)
                {
                    structurecheck.radius      = 3.0f;
                    structurecheck.position.y += 2f;
                }
            }
            timer.Once(0.05f, () => structurecheck.CheckCollision());
        }
コード例 #16
0
        bool GetStructureClean(StructureComponent initialBlock, float playerRot, StructureComponent currentBlock, out Dictionary <string, object> data)
        {
            data         = new Dictionary <string, object>();
            posCleanData = new Dictionary <string, object>();
            rotCleanData = new Dictionary <string, object>();
            if (!GameObjectToPrefab.ContainsKey(currentBlock.gameObject.name))
            {
                return(false);
            }
            normedPos  = GenerateGoodPos(initialBlock.transform.position, currentBlock.transform.position, playerRot);
            normedYRot = currentBlock.transform.rotation.ToEulerAngles().y - playerRot;

            data.Add("prefabname", GameObjectToPrefab[currentBlock.gameObject.name]);

            posCleanData.Add("x", normedPos.x);
            posCleanData.Add("y", normedPos.y);
            posCleanData.Add("z", normedPos.z);
            data.Add("pos", posCleanData);

            rotCleanData.Add("x", currentBlock.transform.rotation.ToEulerAngles().x);
            rotCleanData.Add("y", normedYRot);
            rotCleanData.Add("z", currentBlock.transform.rotation.ToEulerAngles().z);
            data.Add("rot", rotCleanData);
            return(true);
        }
コード例 #17
0
        void BuscarParedes(NetUser Player)
        {
            if (!JugadoresenJuego.Contains(Player) && Player != PlayerExecuteCommand)
            {
                return;
            }
            AtributeRayCharacter = Player.playerClient.rootControllable.idMain.GetComponent <Character>().eyesRay;
            if (MeshBatchPhysics.Raycast(AtributeRayCharacter, out HitRayCastCharacter, out AtributeBolean, out AtributeInstance))
            {
                AtributeCollider = AtributeInstance.physicalColliderReferenceOnly;

                if (AtributeCollider.GetComponent <StructureComponent>() != null)
                {
                    this.paredMadera = AtributeCollider.GetComponent <StructureComponent>();
                    foreach (StructureComponent objs in (Colecciones::HashSet <StructureComponent>)StructureComponents.GetValue(paredMadera.gameObject.GetComponent <StructureComponent>()._master))
                    {
                        if (objs.IsWallType())
                        {
                            TakeDamage.KillSelf(objs);
                        }
                    }
                }
            }
            else
            {
                rust.Notice(Player, "You dont see a WAll Structure ¿?");
            }
        }
コード例 #18
0
 public static void EntityHurt(object entity, ref DamageEvent e)
 {
     try
     {
         HurtEvent he = new HurtEvent(ref e, new Entity(entity));
         if (decayList.Contains(entity))
         {
             he.IsDecay = true;
         }
         if (he.Entity.IsStructure() && !he.IsDecay)
         {
             StructureComponent component = entity as StructureComponent;
             if ((component.IsType(StructureComponent.StructureComponentType.Ceiling) || component.IsType(StructureComponent.StructureComponentType.Foundation)) || component.IsType(StructureComponent.StructureComponentType.Pillar))
             {
                 he.DamageAmount = 0f;
             }
         }
         TakeDamage takeDamage = he.Entity.GetTakeDamage();
         takeDamage.health += he.DamageAmount;
         if (OnEntityHurt != null)
         {
             OnEntityHurt(he);
         }
         Zone3D zoned = Zone3D.GlobalContains(he.Entity);
         if (((zoned == null) || !zoned.Protected) && ((he.Entity.GetTakeDamage().health - he.DamageAmount) > 0f))
         {
             TakeDamage damage3 = he.Entity.GetTakeDamage();
             damage3.health -= he.DamageAmount;
         }
     }
     catch (Exception exception)
     {
         Helper.LogError(exception.ToString(), true);
     }
 }
コード例 #19
0
ファイル: Prod.cs プロジェクト: LouisTakePILLz/Oxide2Plugins
 void cmdChatProd(NetUser netuser, string command, string[] args)
 {
     if (!hasAccess(netuser)) { SendReply(netuser, "You don't have access to this command"); return; }
     cachedCharacter = netuser.playerClient.rootControllable.idMain.GetComponent<Character>();
     if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { SendReply(netuser, "Are you looking at the sky?"); return; }
     if (cachedhitInstance != null)
     {
         cachedCollider = cachedhitInstance.physicalColliderReferenceOnly;
         if (cachedCollider == null) { SendReply(netuser, "Can't prod what you are looking at"); return; }
         cachedStructure = cachedCollider.GetComponent<StructureComponent>();
         if (cachedStructure != null && cachedStructure._master != null)
         {
             cachedMaster = cachedStructure._master;
             var name = PlayerDatabase?.Call("GetPlayerData", cachedMaster.ownerID.ToString(), "name");
             SendReply(netuser, string.Format("{0} - {1} - {2}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "UnknownPlayer" : name.ToString()));
             return;
         }
     }
     else
     {
         cachedDeployable = cachedRaycast.collider.GetComponent<DeployableObject>();
         if (cachedDeployable != null)
         {
             var name = PlayerDatabase?.Call("GetPlayerData", cachedDeployable.ownerID.ToString(), "name");
             SendReply(netuser, string.Format("{0} - {1} - {2}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString()));
             return;
         }
     }
     SendReply(netuser, string.Format("Can't prod what you are looking at: {0}",cachedRaycast.collider.gameObject.name));
 }
コード例 #20
0
        void PasteBuilding(List <object> structureData, Vector3 targetPoint, float targetRot, float heightAdjustment, NetUser netuser)
        {
            Vector3         OriginRotation = new Vector3(0f, targetRot, 0f);
            Quaternion      OriginRot      = Quaternion.EulerRotation(OriginRotation);
            StructureMaster themaster      = null;

            foreach (Dictionary <string, object> structure in structureData)
            {
                Dictionary <string, object> structPos = structure["pos"] as Dictionary <string, object>;
                Dictionary <string, object> structRot = structure["rot"] as Dictionary <string, object>;
                string     prefabname = (string)structure["prefabname"];
                Quaternion newAngles  = Quaternion.EulerRotation((new Vector3(Convert.ToSingle(structRot["x"]), Convert.ToSingle(structRot["y"]), Convert.ToSingle(structRot["z"]))) + OriginRotation);
                Vector3    TempPos    = OriginRot * (new Vector3(Convert.ToSingle(structPos["x"]), Convert.ToSingle(structPos["y"]), Convert.ToSingle(structPos["z"])));
                Vector3    NewPos     = TempPos + targetPoint;
                if (themaster == null)
                {
                    themaster = NetCull.InstantiateClassic <StructureMaster>(Facepunch.Bundling.Load <StructureMaster>("content/structures/StructureMasterPrefab"), NewPos, newAngles, 0);
                    themaster.SetupCreator(netuser.playerClient.controllable);
                }
                StructureComponent block = SpawnStructure(prefabname, NewPos, newAngles);
                if (block != null)
                {
                    themaster.AddStructureComponent(block);
                }
            }
        }
        public string Render(IExpression expr, StructureComponent component = null)
        {
            if (!expr.IsScalar && component == null)
            {
                return(this._opRendererResolver("overall").Render(expr, component));
            }

            IExpression expr1 = expr.OperandsCollection.First();
            IExpression expr2 = expr.Operands["ds_2"];

            string op1 = this._opRendererResolver(expr1.OperatorSymbol).Render(expr1, component);

            string result = string.Empty;

            result = $"{op1} LIKE '%{expr2.ExpressionText.Split("\"")[1]}%'";

            if (expr.ParamSignature != "filter" &&
                (expr.ParentExpression == null || (!expr.ParentExpression.OperatorSymbol.In("and", "or", "xor", "not") && expr.ParentExpression.ParamSignature != "if")) &&
                expr.ContainingSchema.Rulesets.FirstOrDefault(ruleset => ruleset.RulesCollection.Contains(expr.GetFirstAncestorExpr() ?? expr)) == null)
            {
                result = $"IIF({op1} IS NULL, NULL,\nIIF({result}, 1, 0))";
            }

            return(result);
        }
コード例 #22
0
        private object Spawn(string prefab, Vector3 location, Quaternion rotation, int rep)
        {
            prefab = prefab.Trim();
            object obj2 = null;

            try
            {
                for (int i = 0; i < rep; i++)
                {
                    if (prefab == ":player_soldier")
                    {
                        obj2 = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, location, rotation);
                    }
                    else if (prefab.Contains("C130"))
                    {
                        obj2 = NetCull.InstantiateClassic(prefab, location, rotation, 0);
                    }
                    else
                    {
                        GameObject obj3 = NetCull.InstantiateStatic(prefab, location, rotation);
                        obj2 = obj3;
                        StructureComponent component = obj3.GetComponent <StructureComponent>();
                        if (component != null)
                        {
                            obj2 = new Entity(component);
                        }
                        else if (obj3.GetComponent <LootableObject>())
                        {
                            obj2 = new Entity(obj3.GetComponent <LootableObject>());
                        }
                        else if (obj3.GetComponent <SupplyCrate>())
                        {
                            obj2 = new Entity(obj3.GetComponent <SupplyCrate>());
                        }
                        else if (obj3.GetComponent <ResourceTarget>())
                        {
                            obj2 = new Entity(obj3.GetComponent <ResourceTarget>());
                        }
                        else
                        {
                            DeployableObject obj4 = obj3.GetComponent <DeployableObject>();
                            if (obj4 != null)
                            {
                                obj4.ownerID   = 0L;
                                obj4.creatorID = 0L;
                                obj4.CacheCreator();
                                obj4.CreatorSet();
                                obj2 = new Entity(obj4);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError("Spawn error: " + e.ToString());
            }
            return(obj2);
        }
コード例 #23
0
        /// <summary>
        /// Processes a no parameter version of an operator and returns the resulting structure.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <returns>A dynamically defined structure.</returns>
        private IDataStructure ProcessNoParameterFunction(IExpression expression)
        {
            IExpression componentExpr = this._exprFac.GetExpression("comp", ExpressionFactoryNameTarget.OperatorSymbol);
            IExpression ancesorExpr   = null;

            foreach (string name in DatasetClauseOperator.ClauseNames)
            {
                ancesorExpr = expression.GetFirstAncestorExpr(name);
                if (ancesorExpr != null)
                {
                    break;
                }
            }

            if (ancesorExpr == null)
            {
                throw new VtlOperatorError(expression, this.Name, "Expected function parameter.");
            }
            if (expression.CurrentJoinExpr == null)
            {
                IExpression        datasetExpr = ancesorExpr.ParentExpression.OperandsCollection.ToArray()[0];
                StructureComponent component   = datasetExpr.Structure.Identifiers.FirstOrDefault(comp => comp.ValueDomain.DataType == BasicDataType.TimePeriod);
                if (component == null)
                {
                    throw new VtlOperatorError(expression, this.Name, "Could not find time period data type identifier.");
                }
                if (datasetExpr.Structure.Identifiers.Where(comp => comp.ValueDomain.DataType == BasicDataType.TimePeriod).ToArray().Length > 1)
                {
                    throw new VtlOperatorError(expression, this.Name, "Found more than 1 identifier of time period data type.");
                }

                componentExpr.ExpressionText = component.ComponentName.GetNameWithoutAlias();
            }
            else
            {
                string[] aliases = this.GetCompatibleAliases(expression.CurrentJoinExpr.Operands["ds"]);
                if (aliases.Length == 0)
                {
                    throw new VtlOperatorError(expression, this.Name, "Could not find time period data type identifier.");
                }
                if (aliases.Length > 1)
                {
                    throw new VtlOperatorError(expression, this.Name, "Identifier of time period data type has been found in more than 1 join structure.");
                }

                componentExpr.ExpressionText = expression.CurrentJoinExpr.GetAliasExpression(aliases[0]).Structure.Identifiers
                                               .First(id => id.ValueDomain.DataType == BasicDataType.TimePeriod).ComponentName.GetNameWithoutAlias();
            }

            expression.AddOperand("ds_1", componentExpr);
            componentExpr.LineNumber = expression.LineNumber;
            componentExpr.Structure  = componentExpr.OperatorDefinition.GetOutputStructure(componentExpr);

            IDataStructure structure = this._dsResolver("duration_var", ComponentType.Measure, BasicDataType.Duration);

            structure.Components[0].BaseComponentName = componentExpr.Structure.Components[0].BaseComponentName;
            return(structure);
        }
コード例 #24
0
        private static bool smethod_0(TruthDetector truthDetector_0, Vector3 vector3_0, ref Vector3 vector3_1)
        {
            RaycastHit        hit;
            bool              flag;
            MeshBatchInstance instance;
            Vector3           vector = vector3_1 - vector3_0;

            if (vector.magnitude == 0f)
            {
                return(false);
            }
            Ray ray = new Ray(vector3_0 + new Vector3(0f, 0.75f, 0f), vector.normalized);

            if (!Facepunch.MeshBatch.MeshBatchPhysics.SphereCast(ray, 0.1f, out hit, vector.magnitude, 0x20180403, out flag, out instance))
            {
                return(false);
            }
            IDMain             main      = flag ? instance.idMain : IDBase.GetMain(hit.collider);
            GameObject         obj2      = (main != null) ? main.gameObject : hit.collider.gameObject;
            string             newValue  = obj2.name.Trim();
            DeployableObject   obj3      = obj2.GetComponent <DeployableObject>();
            StructureComponent component = obj2.GetComponent <StructureComponent>();

            if (newValue == "")
            {
                newValue = "Mesh Texture";
            }
            else if (obj3 != null)
            {
                newValue = Helper.NiceName(obj3.name);
                if (truthDetector_0.netUser.userID == obj3.ownerID)
                {
                    return(false);
                }
                if (Users.SharedGet(obj3.ownerID, truthDetector_0.netUser.userID))
                {
                    return(false);
                }
            }
            else if (component != null)
            {
                newValue = Helper.NiceName(component.name);
                if (truthDetector_0.netUser.userID == component._master.ownerID)
                {
                    return(false);
                }
                if (Users.SharedGet(component._master.ownerID, truthDetector_0.netUser.userID))
                {
                    return(false);
                }
            }
            PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.WallHack", truthDetector_0.netUser, "", 0, new DateTime());
            PunishDetails = PunishDetails.Replace("%OBJECT.NAME%", newValue);
            PunishDetails = PunishDetails.Replace("%OBJECT.POS%", hit.point.AsString());
            HackDetected  = HackMethod.WallHack;
            vector3_1     = MoveBack(truthDetector_0, vector3_0, vector3_1);
            return(true);
        }
コード例 #25
0
        public string Render(IExpression expr, StructureComponent component = null)
        {
            if (!expr.IsScalar && !expr.IsApplyComponent && component == null)
            {
                return(this._opRendererResolver("overall").Render(expr, component));
            }

            IExpression expr1 = expr.OperandsCollection.ToArray()[0];

            bool isRootExpr =
                !expr.ParamSignature.In("filter", "having") &&
                (expr.ParentExpression == null || (!expr.ParentExpression.OperatorSymbol.In("and", "or", "xor", "not") && expr.ParentExpression.ParamSignature != "if")) &&
                expr.ContainingSchema.Rulesets.FirstOrDefault(ruleset => ruleset.RulesCollection.Contains(expr.GetFirstAncestorExpr() ?? expr)) == null;

            string symbol = expr.OperatorSymbol.ToUpper();
            string op1    = this._opRendererResolver(expr1.OperatorSymbol).Render(expr1, component);

            if (expr.OperandsCollection.ToArray()[0].OperatorSymbol.In("const", "get", "ref", "comp", "#"))
            {
                op1 += " = 1";
            }

            if (symbol != "NOT")
            {
                IExpression expr2 = expr.OperandsCollection.ToArray()[1];

                string result = string.Empty;
                string op2    = this._opRendererResolver(expr2.OperatorSymbol).Render(expr2, component);

                if (expr.OperandsCollection.ToArray()[1].OperatorSymbol.In("const", "ref", "comp"))
                {
                    op2 += " = 1";
                }

                if (symbol != "XOR")
                {
                    result = $"({op1})\n{symbol} ({op2})";
                }
                else
                {
                    result = $"({op1} AND NOT {op2})\nOR (NOT {op1} AND {op2})";
                }

                if (isRootExpr)
                {
                    return($"IIF({result}, 1, 0)");
                }
                return(result);
            }
            else
            {
                if (isRootExpr)
                {
                    return($"IIF(NOT {op1}, 1, 0)");
                }
                return($"{symbol} ({op1})");
            }
        }
コード例 #26
0
        public string Render(IExpression expr, StructureComponent component = null)
        {
            IExpression expr1 = expr.OperandsCollection.ToArray()[0];
            IExpression expr2 = expr.OperandsCollection.ToArray()[1];

            string op1 = $"SELECT * FROM {this._opRendererResolver(expr1.OperatorSymbol).Render(expr1, component)}";
            string op2 = $"SELECT * FROM {this._opRendererResolver(expr2.OperatorSymbol).Render(expr2, component)}";

            StringBuilder result = new StringBuilder();

            if (expr.OperatorSymbol == "union")
            {
                result.AppendLine(op1);
                result.AppendLine("UNION");
                result.AppendLine($"{op1.Replace("*", "ds2.*")} AS ds1");
                result.AppendLine("FULL JOIN (");
                result.AppendLine($"{op2}) AS ds2 ON");
                foreach (StructureComponent identifier in expr1.Structure.Identifiers)
                {
                    result.AppendLine($"ds1.{identifier.ComponentName} = ds2.{identifier.ComponentName} AND");
                }

                result = new StringBuilder(result.ToString().Remove(result.ToString().Length - 5)); // removement of "AND"
                result.AppendLine();
                result.AppendLine($"WHERE ds1.{expr1.Structure.Identifiers[0].ComponentName} IS NULL");
            }
            else if (expr.OperatorSymbol != "symdiff")
            {
                string sqlOperator;
                switch (expr.OperatorSymbol)
                {
                case "intersect": sqlOperator = "INTERSECT"; break;

                case "setdiff": sqlOperator = "EXCEPT"; break;

                default: throw new VtlTargetError(expr, $"Unknow operator keyword: {expr.OperatorSymbol}.");
                }

                result.AppendLine(op1);
                result.AppendLine(sqlOperator);
                result.AppendLine(op2);
            }
            else
            {
                result.AppendLine("SELECT * FROM (");
                result.AppendLine(op1);
                result.AppendLine("EXCEPT");
                result.AppendLine($"{op2}) AS t");
                result.AppendLine("UNION SELECT * FROM (");
                result.AppendLine(op2);
                result.AppendLine("EXCEPT");
                result.AppendLine($"{op1}) AS t");
            }

            return(result.ToString());
        }
コード例 #27
0
ファイル: Hooks.cs プロジェクト: balu92/Fougerite
        public static void EntityHurt(object entity, ref DamageEvent e)
        {
            Contract.Assume(entity != null);

            try
            {
                HurtEvent he = new HurtEvent(ref e, new Entity(entity));
                if (decayList.Contains(entity))
                {
                    he.IsDecay = true;
                }

                if (he.Entity.IsStructure() && !he.IsDecay)
                {
                    StructureComponent component = entity as StructureComponent;
                    if ((component.IsType(StructureComponent.StructureComponentType.Ceiling) || component.IsType(StructureComponent.StructureComponentType.Foundation)) || component.IsType(StructureComponent.StructureComponentType.Pillar))
                    {
                        he.DamageAmount = 0f;
                    }
                }
                TakeDamage takeDamage = he.Entity.GetTakeDamage();
                takeDamage.health += he.DamageAmount;

                // when entity is destroyed
                if (e.status != LifeStatus.IsAlive)
                {
                    DestroyEvent de = new DestroyEvent(ref e, new Entity(entity), he.IsDecay);
                    if (OnEntityDestroyed != null)
                    {
                        OnEntityDestroyed(de);
                    }
                }
                else if (OnEntityHurt != null)
                {
                    OnEntityHurt(he);
                }

                Zone3D zoned = Zone3D.GlobalContains(he.Entity);
                if ((zoned == null) || !zoned.Protected)
                {
                    if ((he.Entity.GetTakeDamage().health - he.DamageAmount) <= 0f)
                    {
                        he.Entity.Destroy();
                    }
                    else
                    {
                        TakeDamage damage2 = he.Entity.GetTakeDamage();
                        damage2.health -= he.DamageAmount;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
コード例 #28
0
        public bool IsNotEligible(Fougerite.Entity en)
        {
            if (en.IsDeployableObject())
            {
                return(false);
            }
            StructureComponent comp = (StructureComponent)en.GetObject <StructureComponent>();

            return(comp._master.ComponentCarryingWeight((StructureComponent)en.Object));
        }
コード例 #29
0
        /// <summary>
        /// Checks if the component is equal to another. <b>Method skips a names comparison.</b>
        /// </summary>
        /// <param name="instance">The compared component.</param>
        /// <param name="component">The component to compare.</param>
        /// <returns>Value specyfing an equality.</returns>
        public static bool EqualsObj(this StructureComponent instance, StructureComponent component)
        {
            if (instance.ComponentType != component.ComponentType ||
                !instance.ValueDomain.EqualsObj(component.ValueDomain))
            {
                return(false);
            }

            return(true);
        }
コード例 #30
0
        StructureComponent SpawnStructure(string prefab, Vector3 pos, Quaternion angle)
        {
            StructureComponent build = NetCull.InstantiateStatic(prefab, pos, angle).GetComponent <StructureComponent>();

            if (build == null)
            {
                return(null);
            }
            return(build);
        }
コード例 #31
0
 public static void StructureMaster_DoDecay(StructureMaster hook, StructureComponent component, ref float damageQuantity)
 {
     object[] array = new object[]
     {
         hook,
         component,
         damageQuantity
     };
     Method.Invoke("RustExtended.RustHook.StructureMaster_DoDecay", array);
     damageQuantity = (float)array[2];
 }
コード例 #32
0
ファイル: Hooks.cs プロジェクト: balu92/Fougerite
 public static void structureKO(StructureComponent sc, DamageEvent e)
 {
     try
     {
         InstaKOCommand command = ChatCommand.GetCommand("instako") as InstaKOCommand;
         if (command.IsOn(e.attacker.client.userID))
         {
             sc.StartCoroutine("DelayedKill");
         }
         else
         {
             sc.UpdateClientHealth();
         }
     }
     catch
     {
         sc.UpdateClientHealth();
     }
 }
コード例 #33
0
        bool GetStructureClean(StructureComponent initialBlock, float playerRot, StructureComponent currentBlock, out Dictionary<string, object> data)
        {
            data = new Dictionary<string, object>();
            posCleanData = new Dictionary<string, object>();
            rotCleanData = new Dictionary<string, object>();
            if (!GameObjectToPrefab.ContainsKey(currentBlock.gameObject.name)) return false;
            normedPos = GenerateGoodPos(initialBlock.transform.position, currentBlock.transform.position, playerRot);
            normedYRot = currentBlock.transform.rotation.ToEulerAngles().y - playerRot;

            data.Add("prefabname", GameObjectToPrefab[currentBlock.gameObject.name]);

            posCleanData.Add("x", normedPos.x);
            posCleanData.Add("y", normedPos.y);
            posCleanData.Add("z", normedPos.z);
            data.Add("pos", posCleanData);

            rotCleanData.Add("x", currentBlock.transform.rotation.ToEulerAngles().x);
            rotCleanData.Add("y", normedYRot);
            rotCleanData.Add("z", currentBlock.transform.rotation.ToEulerAngles().z);
            data.Add("rot", rotCleanData);
            return true;
        }
コード例 #34
0
        object CopyBuilding(Vector3 playerPos, float playerRot, StructureComponent initialBlock, out List<object> rawStructure, out List<object> rawDeployables)
        {
            rawStructure = new List<object>();
            rawDeployables = new List<object>();
            rawSpawnables = new List<object>();
            List<object> houseList = new List<object>();
            List<Vector3> checkFrom = new List<Vector3>();
            StructureComponent fbuildingblock;
            DeployableObject fdeployable;
            IInventoryItem item;

            houseList.Add(initialBlock);
            checkFrom.Add(initialBlock.transform.position);

            Dictionary<string, object> housedata;
            if (!GetStructureClean(initialBlock, playerRot, initialBlock, out housedata))
            {
                return "Couldn't get a clean initial block";
            }
            rawStructure.Add(housedata);

            int current = 0;
            while (true)
            {
                current++;
                if (current > checkFrom.Count)
                    break;
                foreach (var hit in MeshBatchPhysics.OverlapSphere(checkFrom[current - 1], 5f))
                {
                    if (hit.GetComponentInParent<StructureComponent>() != null)
                    {
                        fbuildingblock = hit.GetComponentInParent<StructureComponent>();
                        if (!(houseList.Contains(fbuildingblock)))
                        {
                            houseList.Add(fbuildingblock);
                            checkFrom.Add(fbuildingblock.transform.position);
                            if (GetStructureClean(initialBlock, playerRot, fbuildingblock, out housedata))
                            {
                                rawStructure.Add(housedata);
                            }
                        }
                    }
                    else if (hit.GetComponentInParent<DeployableObject>() != null)
                    {
                        fdeployable = hit.GetComponentInParent<DeployableObject>();
                        if (!(houseList.Contains(fdeployable)))
                        {
                            houseList.Add(fdeployable);
                            checkFrom.Add(fdeployable.transform.position);
                            if (GetDeployableClean(initialBlock, playerRot, fdeployable, out housedata))
                            {
                                if (fdeployable.GetComponent<LootableObject>())
                                {
                                    var box = fdeployable.GetComponent<LootableObject>();
                                    var itemlist = new List<object>();
                                    for (int i = 0; i < box._inventory.slotCount; i++)
                                    {
                                        if (box._inventory.GetItem(i, out item))
                                        {
                                            var newitem = new Dictionary<string, object>();
                                            newitem.Add("name", item.datablock.name);
                                            newitem.Add("amount", item.uses.ToString());
                                            itemlist.Add(newitem);
                                        }
                                    }
                                    housedata.Add("items", itemlist);
                                }
                                rawDeployables.Add(housedata);
                            }
                        }
                    }
                }
            }
            return true;
        }
コード例 #35
0
ファイル: Hooks.cs プロジェクト: 906507516/Oxide
 private void OnStructureBuilt(StructureComponent component, NetUser user)
 {
     HookCalled("OnStructureBuilt");
 }
コード例 #36
0
 /////////////////////////////////////////
 // OnEntityBuilt(Planner planner, GameObject gameobject)
 // Called when a buildingblock was created
 /////////////////////////////////////////
 void OnStructurePlaced(StructureComponent component, IStructureComponentItem item)
 {
     if (item.controllable == null) return;
     if (hasTag(item.controllable.playerClient, "nobuild"))
     {
         if (!hasPermission(item.controllable.playerClient, "canbuild"))
         {
             timer.Once(0.01f, () => DestroyObject(component.gameObject));
             SendMessage(item.controllable.playerClient, "You are not allowed to build here");
         }
     }
 }
コード例 #37
0
ファイル: HooksTest.cs プロジェクト: romgerman/Oxide
 private void OnStructureBuilt(StructureComponent component, NetUser netUser)
 {
     HookCalled("OnStructureBuilt");
     // Print structure built
     Puts(netUser.displayName + " build a " + component.name);
 }
コード例 #38
0
 public static void StructureUCH(IDMain idMain, StructureComponent structureComponent)
 {
     float health = idMain.GetComponent<TakeDamage>().health;
     if (health != structureComponent.oldHealth)
     {
         NetEntityID entID = NetEntityID.Get((UnityEngine.MonoBehaviour)structureComponent);
         NetCull.RemoveRPCsByName(entID, "ClientHealthUpdate");
         if (!beingDestroyed.Contains(idMain.gameObject))
             NetCull.RPC<float>(entID, "ClientHealthUpdate", uLink.RPCMode.OthersBuffered, health);
         else
             beingDestroyed.Remove(idMain.gameObject);
     }
 }
コード例 #39
0
 public bool IsType(StructureComponent.StructureComponentType checkType)
 {
     return this.type == checkType;
 }
コード例 #40
0
ファイル: RustLegacyCore.cs プロジェクト: CypressCube/Oxide
 private object OnStructurePlaced(StructureComponent component, IStructureComponentItem item)
 {
     return Interface.CallHook("OnStructureBuilt", component, item.controllable.netUser);
 }